“无法与主机smtp.gmail.com建立连接”。 Symfony的。 Swiftmailer

时间:2016-10-15 11:21:27

标签: symfony swiftmailer

  • 我有例外:
  

无法与主机smtp.gmail.com建立连接

  • 旧项目Symfony2.8和最新的Symfony3中的相同例外。
  • 我可以ping smtp.gmail.com

enter image description here

3 个答案:

答案 0 :(得分:2)

Avast Antivirus很有罪。

答案 1 :(得分:0)

在Google“帐户设置”中,通过将其设置为“允许”来启用“访问安全性较低的应用”。

Mailer host是您的localhost或127.0.0.1。这不是smtp.google.com

答案 2 :(得分:0)

我将此配置用于我的localhost应用程序

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帐户上使用安全性较低的应用程序。

相关问题