Best emailing approach with template emails

Posted by Harun Baris Bulut on Stack Overflow See other posts from Stack Overflow or by Harun Baris Bulut
Published on 2010-04-07T22:03:54Z Indexed on 2010/04/07 22:43 UTC
Read the original article Hit count: 391

Filed under:
|

Hi all,

We are creating a project with lots of different mail templates in it. There are different messages 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 ?

© Stack Overflow or respective owner

Related posts about php

Related posts about email