Yii2:无法与 godaddy 主机中的主机 smtp.gmail.com [Connection refused #111] 建立连接
Yii2 : Connection could not be established with host smtp.gmail.com [Connection refused #111] in a godaddy hosting
我正在尝试在 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]
请在这方面帮助我。
谢谢,
您的配置似乎有问题,请尝试将您的配置更改为:
'port'=>'465',
'encryption'=>'ssl'
您的 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',
我正在尝试在 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]
请在这方面帮助我。 谢谢,
您的配置似乎有问题,请尝试将您的配置更改为:
'port'=>'465',
'encryption'=>'ssl'
您的 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',