Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send mail with Zend_Mail through Gmail smtp server

I'd like to use Gmail smtp server to send email with Zend_Mail. I had this code

Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Smtp("smtp.googlemail.com", array(
    "auth" => "login",
    "username" => "[email protected]",
    "password" => "mypassword",
    "ssl" => "ssl",
    "port" => 465
)));

but when I try to send an email it throws an Exception with message Connection refused.

Where I'm wrong?

like image 350
Egidio Caprino Avatar asked Dec 27 '22 15:12

Egidio Caprino


1 Answers

Your params are wrong. Give it a shot with these:

$config = array(
    'ssl' => 'tls',
    'port' => 587,
    'auth' => 'login',
    'username' => '[email protected]',
    'password' => 'mypassword'
);
$transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
Zend_Mail::setDefaultTransport($transport);
like image 170
David Snabel-Caunt Avatar answered Jan 14 '23 06:01

David Snabel-Caunt