提问人:Beelal 提问时间:2/21/2023 更新时间:3/4/2023 访问量:89
为什么没有从我的网站发送电子邮件?
Why emails are not sending from my website?
问:
我在使用 . 发送电子邮件时遇到问题。我无法从我的网站转发电子邮件。Yii2 swiftmailer
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtpout.secureserver.net',
'username' => '[email protected]',
'password' => 'mypassword',
'port' => '465',
'encryption' => 'ssl',
],
'useFileTransport' => true,
],
我应该怎么做?
我不知道该怎么办。
答:
0赞
DarkShade
2/21/2023
#1
有任何错误消息吗? 您可以使用 编写和查看错误日志。'enableSwiftMailerLogging' => true,
如果它出现ssl错误,您可以通过以下代码摆脱ssl错误
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtpout.secureserver.net',
'username' => '[email protected]',
'password' => 'mypassword',
'port' => '465',
'encryption' => 'ssl',
'streamOptions' => [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
],
'streamOptions' => ['ssl' => ['verify_peer' => false, 'verify_peer_name' => false]],
'streamOptions' => ['ssl' => ['allow_self_signed' => true]],
'streamOptions' => ['ssl' => ['verify_depth' => false]],
],
'enableSwiftMailerLogging' => true,
将 verify_peer 设置为 false 可能会使应用程序面临安全风险,因为它会禁用对等方的 SSL/TLS 证书的验证。
1赞
Senthil
3/1/2023
#2
这可能是因为您将 useFileTransport 设置为 true。如果将其设置为 True,则电子邮件将另存为 $fileTransportPath 下的文件,而不是将其发送给实际收件人。
0赞
Hemangi khatri
3/4/2023
#3
请使用设置为 false 的 'useFileTransport' 选项。将其设置为 true:这意味着电子邮件不会通过 SMTP 服务器发送,而是保存在文件系统的 runtime/mail 目录下。这可能是您的电子邮件未发送的原因。
评论