gpt4 book ai didi

php - Yii2 : Connection could not be established with host smtp. gmail.com [Connection refused #111] 在 godaddy 主机中

转载 作者:可可西里 更新时间:2023-10-31 23:45:02 28 4
gpt4 key购买 nike

我正在尝试在 Yii2 中使用 Swift Mailer。

我的主机是 Godaddy,我正在尝试使用 gmail 帐户发送电子邮件。

代码似乎工作正常,但当我尝试使用它时,我收到错误:无法与主机 smtp.gmail.com 建立连接 [连接被拒绝 #111]

我仔细检查了我是否使用了正确的 gmail 凭据。这可能是我的主机的问题吗?如果是,有没有办法解决它?这是代码

'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'transport' => [
'class' => 'Swift_SmtpTransport',
'host'=>'smtp.gmail.com',
'username'=>'myUserName@gmail.com',
'password'=>'******',
'port'=>'587',
'encryption'=>'tls',
],
'useFileTransport' => false, //for the testing purpose, you need to enable this


],
I also tried with **`'class' => 'Swift_MailTransport',`**
but the error was not resolved.

The error is

Connection could not be established with host smtp.gmail.com [Connection refused #111]

请在这方面帮助我。谢谢,

最佳答案

您的 Swift Mailer 配置设置似乎无法连接主机 Gmail,请尝试以下更改,很可能会起作用:

'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host'=>'smtp.gmail.com',
'username'=>'myUserName@gmail.com',
'password'=>'******',
'port'=>'465',
'encryption'=>'ssl',
],
],

所做的更改:

'port'=>'465',
'encryption'=>'ssl',

关于php - Yii2 : Connection could not be established with host smtp. gmail.com [Connection refused #111] 在 godaddy 主机中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47062030/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com