Best emailing approach with template emails
We are creating a project with lots of different mail templates in it. There are different mes开发者_StackOverflow社区sages for different purposes and we are trying to make the coding easy and understandable for the future.
By the way we have different transport classes like e-mail, sms, twitter vs...
Now we are doing this but I dont know if there is a better solution.
We have a class called
H2B_Message_Container_Mail_About_Blablabla
it has 4 methods;
interface H2B_Message_Mail_Interface
{
public function setName($name);
public function setValue($key, $value);
public function getMailBody();
public function getMailSubject();
}
and in the mail body there are various variables as expected.
before we send the mail, we get the variable values from the database with JSON format and decode it.
Then we send it like;
$mail = new H2B_Message_Mail();
$mail->setTemplate($newTemplate);
$mail->send();
The question is; is there a better way to do this ?
- The method
send
is not in your interface - The transport type should be configurable I think.
Your interface looks like Zend_Mail
. This is a somewhat simple interface which might be good enough for you. But if you want to send e-mails with embedded images it is better to further split your interfaces. Better you just use Swiftmailer
, according to many the best Php Mailer.
精彩评论