"Connection could not be established with host smtp.gmail.com"。交响乐。 Swiftmailer
"Connection could not be established with host smtp.gmail.com". Symfony. Swiftmailer
- 我遇到异常:
Connection could not be established with host smtp.gmail.com
- 旧项目 Symfony2.8 和最新 Symfony3 中的相同异常。
- 我可以 ping
smtp.gmail.com
。
在 Google "Account settings" 中通过将 "Access for less secured apps" 设置为 "Allow" 来启用 "Access for less secured apps"。
邮件主机是您的本地主机或 127.0.0.1。这不是 smtp.google.com
我正在为我的本地主机应用程序使用此配置
parameters:
mailer_transport: gmail
mailer_host: smtp.gmail.com
mailer_user: youremail@gmail.com //replace by your gmail account
mailer_password: ********** //replace by your gmail password
config.yml:
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
你的控制器代码好像和我的一样。
正如 napestershine 在他的回复中所说,不要忘记在您的 gmail 帐户上允许安全性较低的应用程序。
Avast Antivirus 有罪。
- 我遇到异常:
Connection could not be established with host smtp.gmail.com
- 旧项目 Symfony2.8 和最新 Symfony3 中的相同异常。
- 我可以 ping
smtp.gmail.com
。
在 Google "Account settings" 中通过将 "Access for less secured apps" 设置为 "Allow" 来启用 "Access for less secured apps"。
邮件主机是您的本地主机或 127.0.0.1。这不是 smtp.google.com
我正在为我的本地主机应用程序使用此配置
parameters:
mailer_transport: gmail
mailer_host: smtp.gmail.com
mailer_user: youremail@gmail.com //replace by your gmail account
mailer_password: ********** //replace by your gmail password
config.yml:
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
你的控制器代码好像和我的一样。
正如 napestershine 在他的回复中所说,不要忘记在您的 gmail 帐户上允许安全性较低的应用程序。
Avast Antivirus 有罪。