
Typically you’d never like to send a non-html formatted mail from your web system. It’s ugly and it’s difficult to read. Instead of sending pure text, you’d like to add some images and styles. The way you can do it with Zend_Mail is simple enough. Replace the setBody method with setBodyHtml. Isn’t that natural?
// before
$mail = new Zend_Mail('utf-8');
$mail->setFrom('sender@example.com', 'Sender Name');
$mail->setBody('message in Html');
$mail->addTo('recipient@example.com', 'Recepient Name');
$mail->setSubject('Subject');
$mail->send(); |
// before
$mail = new Zend_Mail('utf-8');
$mail->setFrom('sender@example.com', 'Sender Name');
$mail->setBody('message in Html');
$mail->addTo('recipient@example.com', 'Recepient Name');
$mail->setSubject('Subject');
$mail->send();
// after
$mail = new Zend_Mail('utf-8');
$mail->setFrom('sender@example.com', 'Sender Name');
$mail->setBodyHtml('message in Html');
$mail->addTo('recipient@example.com', 'Recepient Name');
$mail->setSubject('Subject');
$mail->send(); |
// after
$mail = new Zend_Mail('utf-8');
$mail->setFrom('sender@example.com', 'Sender Name');
$mail->setBodyHtml('message in Html');
$mail->addTo('recipient@example.com', 'Recepient Name');
$mail->setSubject('Subject');
$mail->send();