Send mail with Zend_Mail through the Gmail SMTP server

I would like to use the Gmail SMTP server to send email using Zend_Mail . I had this code

Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Smtp("smtp.googlemail.com", array( "auth" => "login", "username" => " myusername@gmail.com ", "password" => "mypassword", "ssl" => "ssl", "port" => 465 ))); 

but when I try to send an email, it throws an exception with the message Connection refused .

Where am I mistaken?

+4
source share
1 answer

Your parameters are wrong. Give him a chance:

 $config = array( 'ssl' => 'tls', 'port' => 587, 'auth' => 'login', 'username' => ' myusername@gmail.com ', 'password' => 'mypassword' ); $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config); Zend_Mail::setDefaultTransport($transport); 
+10
source

All Articles