How to send email via SMTP using Zend Framework

Zend Framework already provides the Zend_Mail library to send out email from your website. It’s like using the simple PHP mail function to send out email. However the similarity stops there. You can code Zend_Mail to use SMTP to send out email which is not possible in the mail function. All you have to do is use the Zend_Mail_Transport_Smtp library to set the SMTP account details and then set the transport method in Zend_Mail to this transport object. Review the code below

$config = array('auth' => 'login',
		'username' => '',
		'password' => '');
$transport = new Zend_Mail_Transport_Smtp('', $config);

$mail = new Zend_Mail();
$mail->setFrom(, '');
try {
//This is where Zend_Mail is told how to send the email
} catch (Exception $e){

Be the first to comment

Leave a Reply