Symfony 4 SwiftMailer Gmail : Email not sent

陌路散爱 提交于 2019-11-30 21:07:57

Problem solved!! Put this configuration instead of using the URL env variable

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

Late to the party, but the URL format requires full settings. I don't think SwiftMailer parses the URL to detect a specific transport (like gmail) to configure the reset by itself.

The following format worked for me:

MAILER_URL=smtp://smtp.gmail.com:587?encryption=tls&username=USERNAME&password=PASSWORD

MAILER_URL must be url encoded. Check out the documentation at: https://symfony.com/doc/current/email.html#configuration

If your password had some special characters in it, that needed to be url encoded, it won't work.

Hope it helps.

In my experience, you will need enable "Allow unsafe logins" in a Google Suite or Gmail account since they prevent access via SMTP.

Comment out the spooler line

swiftmailer:
url: '%env(MAILER_URL)%'
#spool: { type: 'memory' }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!