Sending Emails with Zend_Mail and Yahoo! SMTP

Posted on Updated on

When developers are trying to test emails with popular email service providers from the local server environments, it does not allow to send emails since they try to impose restrictions on spamming. Followings can be used to test email contact forms with Zend Framework and its mail function. It is tested and worked fine with yahoo SMTP settings but on zend framework. Here the trick was setting from email as same as the authenticated email address.

//values from  zend form elements
$sender = $form->getValue(‘name’);
$email = $form ->getValue(’email’);
$subject = $form ->getValue(‘subject’);
$message = $form ->getValue(‘message’);

$mail = new Zend_Mail();
$config = array(‘auth’ => ‘login’,’username’ => ‘’,’password’ => ‘your_password’);
$transport = new Zend_Mail_Transport_Smtp(‘’, $config);

$mail->setFrom(‘’, $sender); //should be the same email used for config
$mail->setReplyTo($email, $sender);
$mail->addTo(‘ ‘, ‘webmaster’);
$mail->setBodyHtml(’email body text in html’);
$mail->setBodyText(’email body text in text’);


cheers! 🙂