I am working on a site where users create their accounts. I need to send email to users in many oceans. For example, during registration, you forgot your password, order summary, etc. I want to use email templates for this. I need your suggestions. I want to use a way that if I change any email template or login in less time and change.
I thought of the following:
I have a table for email templates like this:
id emailSubject emailBody emailType
For example, when a user forgot a password:
ID:
1
post message:
ABC: Link for Password Change
emailBody:
<table border=0> <tr><td> <b> Dear [[username]] <b/> </td></tr> <tr><td> This email is sent to you in response of your password recovery request. If you want to change your password, please click the following link:<br /> [[link1]] <br/> If you don't want to change your password then click the following link:<br/> [[link2]] </tr></td> <tr><td> <b>ABC Team</b> </td></tr> </table>
EmailType:
ForgotPassword
Prepare email data:
$emailFields["to"] = " user@abc.com "; $emailFields["username"] = "XYZ"; $emailFields["link1"] = "http://abc.com/changepassword?code='123'"; $emailFields["link2"] = "http://abc.com/ignorechangepasswordreq?code='123'"; $emailFields["emailTemplate"] = "ForgotPassword";
Now pass all the fields to this function to send email:
sendEmail( $emailFields ){ // Get email template from database using emailTemplate name. // Replace all required fields(username, link1,link2) in body. // set to,subject,body // send email using zend or php }
I planned to use the above method. Can you suggest a better way or some kind of change in the logic above.
Thanks.
source share