More Zend Framework Fun

Hold on Cowboy

This blog post is pretty old. Be careful with the information you find in here. It's likely dead, dying, or wildly inaccurate.

Sending email via Gmail 

$config = array( ‘ssl’ => ‘tls’, ‘port’ => 587, ‘auth’ => ‘login’, ‘username’ => ‘youemail@gmail.com’, ‘password’ => ‘yourpassword’ );

$gmail = new Zend_Mail_Transport_Smtp(‘smtp.gmail.com’, $config); $mail = new Zend_Mail(); $mail->addTo($this->to); $mail->setSubject($this->subject); $mail->setFrom($this->from); $mail->setBodyText($this->body);

$mail->send($gmail);

As you can see, you need to create an object for Gmail, then create an email object, then tell the email object to use the gmail object. It works great.


Did this help you out? It took me a few days to piece together all this information together, I hope this saves you some time (who knows, maybe the future me will be thankful I wrote this down). Let me know your thoughts. shanestillwell@gmail.com