Send an email with Zend_Mail using Gmail’s smtp services

SSL support on your http server must be enabled .
Before you continue , in php.ini used by your http server enable openssl extention and restart the http server .

Now in your application bootstrap file use next code snippet :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
try {
 
$config = array('auth' => 'login',
          'username' => 'your@gmail.com',
          // in case of Gmail username also acts as mandatory value of FROM header
          'password' => 'gmail_password','ssl' => 'tls','port' => 587);
 
          $mailTransport = new Zend_Mail_Transport_Smtp('smtp.gmail.com',$config);
          Zend_Mail::setDefaultTransport($mailTransport);
          // defines gmail smtp infrastructure as default for any email message originated by Zend_Mail.
 
} catch (Zend_Exception $e) {
         // Here you can log an Zend_Mail exceptions</strong>
}