Using Zend_Mail and Google SMTP to send emails

You can set this globally, for example in your bootstrap.php file:

$tr = new ZendMailTransportSmtp('', array( 'auth' => 'login', 'username' => 'YOURUS[email protected]', 'password' => 'YOURPASSWORD', 'ssl' => 'ssl', 'port' => 465) ); ZendMail::setDefaultTransport($tr);

And later just use the normal Zend_Mail function as usual:

$mail = new ZendMail(); $mail->setBodyHtml('Your html email here.'); $mail->addTo('send[email protected]'); $mail->setSubject('Mail Subject'); $mail->setFrom('[email protected]'); $mail->send();

To quickly explain the settings:
You need to set the authentication type to login, and provide your Google email and password, as obviously to prevent spam Google needs some verification of who you are. Then we specify the ssl type: Zend supports tls and ssl, and for Google we need to specify the later one. This also means that we need to use port 465 instead of the standard 25.