Skip to content

Zend Framework : Sending emails using Zend_Mail and Google Smtp

Sending emails using Zend_Mail component from Zend Framework is an easy as it can get task. On a recent project, i needed to configure Zend_Mail to work with Google Smtp server.

Here is a quick how to:

$settings = array('ssl'=>'ssl',
                                'auth' => 'login',
                                'username' => '[email protected]',
                                'password' => 'YOUR_PASSWORD');
                $transport = new Zend_Mail_Transport_Smtp('', $settings);
                $email_from = "YOUR_EMAIL";
                $name_from = "YOUR NAME";
                $email_to = "TO_EMAIL";
                $name_to = "TO NAME";
                $mail = new Zend_Mail ();
                $mail->setReplyTo($email_from, $name_from);
                $mail->setFrom ($email_from, $name_from);
                $mail->addTo ($email_to, $name_to);
                $mail->setSubject ('Testing email using google accounts and Zend_Mail');
                $mail->setBodyText ("Email body");

Don’t even bother to add a different email to $email_from than your Google email, because Google will override your settings by you account email.

Update: Got a tip from Bruno Pedro, Google has smtp sending limits, you can only send up to 500 emails using a Google standard account. Read the Google answer on this limiting issue, for more info.

For a more detailed look, just check out Zend_Mail component page.

Published inCodingphp


  1. thank you very much!

    i do it follow you,but it doesn’t work.

  2. karthik karthik

    very neat site but didnt work .. i got the error of

    No connection could be made because the target machine actively refused it.

  3. Neil Neil

    Thanks for that integration help. Works on my application fine.

  4. Thank you for the sensible critique. Me and my neighbor were just preparing to do a little research about this. We got a grab a book from our local library but I think I learned more from this post. I am very glad to see such excellent information being shared freely out there.

  5. This can turn into an addictive passion and is something the whole family can enjoy.

    However, you must completely do your research beforehand.

    Pinpointing shades now is easier and you will get
    the join your enemies.

  6. cany cany

    hello sir,

    am beginer i dont know where to place this code in controller , form, model and how to call from .phtml

  7. The best way to do this is through ensuring that you are using the official plugin – whether you’re using Word – Press or another blogging platform. The tone appeals to readers and they are more likely to trust the content and to get involved.

Leave a Reply

Your email address will not be published. Required fields are marked *