php - Symfony 4 SwiftMailer Gmail : Email not sent

标签 php gmail swiftmailer symfony4

我目前正在开发 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

After completing a form

这是我遵循的文档: 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/

相关文章:

php - json_decode 和 PHP : JSON_BIGINT_AS_STRING disparity

php - 根据值扩展 2 个数组

javascript - Mailto 链接未在 Chromebook 上复制电子邮件正文

php - Laravel SSL 读取操作超时 | swift _IoException | PHP错误?

php - 段错误(核心转储)Laravel SwiftMailer

php - 通过 PHPMailer 添加附件

javascript - 如何限制每页显示的图像数量?

php - 使用核心 php mail() 通过 gmail SMTP 发送

java - 在谷歌开发者控制台上注册网络应用程序

php - 如何使用 PHP 中的 Swiftmailer 库发送带有 STARTTLS 和自签名证书的邮件