我目前正在开发 Symfony 4 应用程序,我需要通过 Swift Mailer 发送电子邮件。 当我发送电子邮件时,我收到了假脱机的电子邮件,但我没有在我的 Gmail 邮箱中收到它。 我在我的 gmail 配置中允许使用不安全的应用程序。
这是我来自 .env 文件的邮件程序 URL:MAILER_URL=gmail://ep****@gmail.com:PASSWORD@localhost
这是我的 swiftmailer.yaml:
#config/packages/swiftmailer.yaml
swiftmailer:
url: '%env(MAILER_URL)%'
spool: { type: 'memory' }
这是我的 Controller 函数:
src/Controller/AccountController.php
这是我遵循的文档: http://symfony.com/doc/current/email.html
我已经检查了这些问题,但他们没有给我答案:How to send emails with Symfony 4 Swiftmailer from a local machine running on Windows 10? , mailer symfony 4 not working
拜托,我需要帮助。我整天都在寻找解决方案。我没有收到任何错误,但我没有收到邮件。 提前致谢。任何链接都可以帮助我。
最佳答案
问题解决了!! 放置此配置而不是使用 URL 环境变量
swiftmailer:
transport: gmail
username: ****@gmail.com
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
关于php - Symfony 4 SwiftMailer Gmail : Email not sent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48915515/