tags:

views:

37

answers:

1

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 ?

+1  A: 
  1. The method send is not in your interface
  2. 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.

Exception e
+1 for the SwiftMailer reccommendation.
prodigitalson
I dont have problem with mailing but storing the templates and working with them. Also we dont want to send image just writings. By the way the code above is not the actual code, I simplified you to understand easyly.
Harun Baris Bulut