Send mail with Zend_Mail through Gmail smtp server

余生长醉 提交于 2019-12-10 16:08:23

问题


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" => "myusername@gmail.com",
    "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?


回答1:


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

$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);


来源:https://stackoverflow.com/questions/7038580/send-mail-with-zend-mail-through-gmail-smtp-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!