简体   繁体   English

使用Swiftmailer在Heroku中发送电子邮件的问题

[英]Problem with sending emails in Heroku using Swiftmailer

I wrote an application in symfony 4. I deployed it on the heroku. 我用symfony 4编写了一个应用程序。我将其部署在heroku上。 Everything works as it should with the exception of sending emails. 除发送电子邮件外,其他所有操作均应正常进行。 When I trying to send an e-mail from the console like this: 当我尝试像这样从控制台发送电子邮件时:

heroku run php bin/console swiftmailer:email:Send

Exception occurred while flushing email queue: Failed to authenticate on SMTP server with username "healthcard95@gmail.com" using 1 possible authenticat ors. 刷新电子邮件队列时发生异常:无法使用1个可能的身份验证在用户名为“ healthcard95@gmail.com”的SMTP服务器上进行身份验证。 Authenticator LOGIN returned Swift_TransportException: Expected response code 235 Please log in via your web browser and then try again. 身份验证器LOGIN返回Swift_TransportException:预期的响应代码235请通过您的Web浏览器登录,然后重试。 Learn more at https://support.google.com/mail/answer/78754 i65sm11848023qkh.49 - gsmtp " in /app/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:457 要了解更多信息, 访问/app/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:457中的https://support.google.com/mail/answer/78754 i65sm11848023qkh.49-gsmtp

This is my swiftmailer.yaml file: 这是我的swiftmailer.yaml文件:

swiftmailer: transport: gmail username: username password: ******** host: localhost port: 465 encryption: ssl auth-mode: login spool: { type: 'memory' } stream_options: ssl: allow_self_signed: true verify_peer: false verify_peer_name: false

How to fix this error? 如何解决这个错误?

The problem is in Gmail. 问题出在Gmail中。 Although I have set up security to allow less secure applications and e-mails from local hosts are sent correctly when I perform the same operation in gmail heroku, I see a new device - unfortunately I can't add it to trusted devices, therefore it's blocked. 尽管我已设置安全性以允许安全性较低的应用程序,并且当我在gmail heroku中执行相同的操作时可以正确发送来自本地主机的电子邮件,但我看到了一个新设备-不幸的是,我无法将其添加到受信任的设备中,因此受阻。

The solution was to change mail, eg on yandex.com. 解决方案是更改邮件,例如在yandex.com上。 Here is an example file swiftmailer.yaml correctly configured for heroku: 这是为heroku正确配置的示例文件swiftmailer.yaml:

 swiftmailer: transport: smtp username: username password: ******** host: smtp.yandex.com port: 465 encryption: ssl auth-mode: login spool: { type: 'memory' } stream_options: ssl: allow_self_signed: true verify_peer: false verify_peer_name: false 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM