Tal*_*han 5 php email smtp swiftmailer yii2
我正在尝试在 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
Run Code Online (Sandbox Code Playgroud)
无法与主机 smtp.gmail.com 建立连接 [连接被拒绝 #111]
请在这方面帮助我。谢谢,
小智 1
您的 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',
],
],
Run Code Online (Sandbox Code Playgroud)
所做的更改:
'port'=>'465',
'encryption'=>'ssl',
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4419 次 |
最近记录: |