Search code examples
phpemailtemplatestemplate-engine

Maintainable automatic mail system


Rather an advanced question.

The application of our company sends a number of emails to our users. Some are send daily, some weekly, ... The emails are in "standard" company format and contain text that is (partially) loaded from the database. The text is for example dependent of the language of the user.

How can I build this system, so it would be easy to maintain?

Right now, the emails are created in a PHP script:

  • The script selects the users from te database that need to receive a mail.
  • It creates the email text, using data from the database (eg: $text = "Dear ".$user['Username'])
  • This text is parsed with PHP templates. The template contains the default layout.

But if we want to adjust something small to the emails, I have to do it in the code. Which is not my job, people from marketing would prefer being able to do this directly..

Any ideas on how to pull this of technologically, in a performant maintainable way?


Solution

  • Well, if i get your point you could have the text for the mail template stored in the database. When somebody wants to change the content, they could have a front-end where they do their preferred changes in.