I am working on a website where Users create their accounts. I need to send email to users on many oceans. For example when signup, forgot password, order summary etc. I want to use emails templates for this. I need your suggestions for this. I want to use a way that If I change any email template or login in less time and changes.
I have thought about the following way:
I have a table for email templates like this:
id
emailSubject
emailBody
emailType
For example when user forgot password:
id:
1
emailSubject:
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"] = "[email protected]";
$emailFields["username"] = "XYZ";
$emailFields["link1"] = "http://abc.com/changepassword?code='123'";
$emailFields["link2"] = "http://abc.com/ignorechangepasswordreq?code='123'";
$emailFields["emailTemplate"] = "ForgotPassword";
Now Pass the all 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 planed to use above method. Can you suggest better way or some change in above logic.
Thanks.