Home » Php » php – Symfony 4 SwiftMailer Gmail : Email not sent

php – Symfony 4 SwiftMailer Gmail : Email not sent

Posted by: admin July 12, 2020 Leave a comment


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 my Gmail Mailbox.
I allowed unsecure apps in my gmail configuration.

This is my mailer URL from .env file : MAILER_URL=gmail://ep****@gmail.com:[email protected]

This is my swiftmailer.yaml:

        url: '%env(MAILER_URL)%'
        spool: { type: 'memory' }

This is my controller function:


After completing a form

This is the documentation I’ve followed :

I’ve checked these questions but they don’t give me the answer : How to send emails with Symfony 4 Swiftmailer from a local machine running on Windows 10? , mailer symfony 4 not working

Please, I need help. I’ve looked for the solution all day long. I get no errors but I don’t receive the mail.
Thanks in advance. Any link can help me.

How to&Answers:

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

    transport:        gmail
    username:         ****@gmail.com
    password:         *******
    host:             localhost
    port:             465
    encryption:       ssl
    auth-mode:        login
    spool: { type: 'memory' }
            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:



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

url: '%env(MAILER_URL)%'
#spool: { type: 'memory' }


MAILER_URL must be url encoded. Check out the documentation at:

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

Hope it helps.