Symfony 4 SwiftMailer Gmail : Email not sent

前端 未结 5 811
攒了一身酷
攒了一身酷 2021-01-02 17:48

I\'m currently working on a Symfony 4 application and I need to send emails throught Swift Mailer. When I send an email, I receive the email spooled but I don\'t get it in m

相关标签:
5条回答
  • 2021-01-02 18:01

    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
    
    0 讨论(0)
  • 2021-01-02 18:07

    Comment out the spooler line

    swiftmailer:
    url: '%env(MAILER_URL)%'
    #spool: { type: 'memory' }
    
    0 讨论(0)
  • 2021-01-02 18:11

    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
    
    0 讨论(0)
  • 2021-01-02 18:22

    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.

    0 讨论(0)
  • 2021-01-02 18:25

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

    0 讨论(0)
提交回复
热议问题