[英]zf2 - gmail smtp not working
我之前發送郵件的smtp設置如下,工作正常。
$options = new Mail\Transport\SmtpOptions(array(
'name' => 'gmail.com',
'host' => 'smtp.gmail.com',
'port' => 465,
'connection_class' => 'login',
'connection_config' => array(
'username' => 'myname@mywebsite.com',
'password' => 'password',
'ssl'=> 'ssl',
),
));
$transport = new Mail\Transport\Smtp($options);
$transport->send($mail);
但如果我使用另一個帳戶
$options = new Mail\Transport\SmtpOptions(array(
'name' => 'gmail.com',
'host' => 'smtp.gmail.com',
'port'=> 465,
'connection_class' => 'login',
'connection_config' => array(
'username' => 'mynewname@gmail.com',
'password' => 'newpassword',
'ssl'=> 'ssl',
),
));
$transport = new Mail\Transport\Smtp($options);
$transport->send($mail);
它給出了如下所示的錯誤
我做錯了什么。請幫忙。 我是新來的。
我創建了一個自動加載文件mail.local.php
其中包含以下內容,它對我mail.local.php
!
return array(
'smtp' => array(
'transport' => array(
'options' => array(
'host' => 'smtp.gmail.com',
'connection_class' => 'plain',
'port' => '587',
'connection_config' => array(
'username' => 'my-gmail-email-d',
'password' => 'my-email-password',
'ssl' => 'tls'
),
),
),
)
);
你可以通過將端口從465
改為587
並刪除'connection_class' => 'login'
嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.