Our website needs to send transactional emails to customers each time an event happens on the site such as:

  • User registration
  • Email verification
  • Password resets
  • Order confirmations
  • Despatch confirmations
  • Comment notifications

And so on.

At the moment I am storing the email templates within an application page (email.cfc which could also be email.php or whatever language you use). Whenever an event happens, I pass in parameters like the user's email address and name to the email template and it fires off an email.

What would be the best way to manage email templates that need to be sent out for regular transactions? Should we:

  • Store the templates in a DB and try to use string replacement to inject dynamic variables like the name, orderid, email address
  • Keep them within the application only
  • Some other method

I would really like to know how large companies do it so I can start off in a best-practice way that is scalable.

1 Answer 1


If you use any localization in your application (with a larger user base you probably need to do that) the most natural place for such templates is the localization file storage, and the varying parts will be handled with string replacement. As a developer, I would use that approach (file system and string replacement) even if only one language is supported at the moment.

  • What is the localization file storage and how would I go about setting one up? Can you give me any links please?
    – volume one
    Feb 15, 2019 at 12:20
  • I can't name a specific one, depends on the php framework that you're using. Have you searched for localization/internationalization already? Feb 15, 2019 at 12:39
  • I'm actually using ColdFusion and have read about a localisation "Resource Bundle" which contains localised versions of text learncfinaweek.com/week1/i18n However it doesn't say where to store all this other than in a struct for a very simple example
    – volume one
    Feb 15, 2019 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.