Best emailing approach

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_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 ?

I would suggest using Smarty or PHPTal etc, which gives you the ability to do loops etc and all the usual advantages that come with template engines, otherwise you’ll have to be specific if the answer you’re after is more like a solution to a problem you have…