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.