Personalised e-mails with if clauses

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!


I am building a system to deal with inscriptions to events. There is a
backoffice which allows administrators to send emails to all or to a sub-set
of the participants. The administrators can enter the text of the emails,
using a template-like syntax to add fields from the database. For example :
"Dear Personalised e mails with if clauses " will produce "Dear John Doe". But I
would need to add a degree in the way emails can be personalised, with if
... elseif ... elseif ... else ... clauses.

For example :
{if (transport = 'train')}
    We noted that you will come by train + instructions to come from the
train station.
{elseif (transport = 'plane')}
    We noted that you will fligh to Paris + instructions to come....
{elseif (transport = 'car')}

I could use PHP syntax for the content of the mail and just eval( ) it or do
something like that, but I don't want to allow anything else than if ...
elseif ... else ... clauses. I could also use a template system (Smarty) but
for many reasons I don't use any of those anymore.

Can you give me an idea about how to do this ?



Site Timeline