Search code examples
emailsymfonyamazon-web-servicesswiftmaileramazon-ses

Symfony 2 Swiftmailer + Amazon SES: Failed to authenticate on SMTP server with username "XXXXXXXXXXXXXXXX" using 2 possible authenticators


I know this question have been asked before but any of the given responses read have become into a solution for this scenario with Symfony2 + Swiftmailer + Amazon SES.

I setup Amazon SES account details for Swiftmailer in Symfony2, all the information is correct, user name and password. However by some weird reason I don't catch up Symfony2 Swiftmailer drops me this error while sending the email.

Failed to authenticate on SMTP server with username "XXXXXXXXXXXXXXXX" using 2 possible authenticators

This is what I got in config.yml

#app/config/config.yml

# Swiftmailer Configuration
swiftmailer:
    transport: "%mailer_transport%"
    host:      "%mailer_host%"
    port:      "%mailer_port%"
    encryption: "%encryption%"
    username:  "%mailer_user%"
    password:  "%mailer_password%"

And parameters.yml

#app/config/parameters.yml

parameters:
    database_driver: pdo_mysql
    database_host: 127.0.0.1
    database_port: null
    database_name: mydatabase
    database_user: dbuser
    database_password: dbpass
    mailer_transport: smtp
    mailer_host: email-smtp.us-east-1.amazonaws.com
    mailer_port: 587
    encryption: tls
    mailer_user: XXXXXXXXXXXXXXXX
    mailer_password: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    mailer_from: [email protected]
    locale: en
    secret: ThisTokenIsNotSoSecretChangeIt
    debug_toolbar: true
    debug_redirects: false
    use_assetic_controller: true

Placing a Gmail smtp details instead Amazon SES works just fine and sends email rightly. But with Amazon SES configuration it doesn't. I repeat, user name is correct, it works with Amazon SES Mailer library, but does not do it with Symfony integrated Swiftmailer.

Some thoughts?


Solution

  • All your configuration parameters I think are just fine like in the Symfony2 documentation states http://symfony.com/doc/current/cookbook/email/cloud.html

    If with the Amazon SES Mailer library which is part of the AWS SDK it works, then check if you are using the right credentials for the SMTP solution with Swiftmailer in Symfony2.

    When you use the AWS SDK you use the AWS access keys to access the SES API and be able to send email using the Amazon SES Mailer included in that SDK.

    When you use another library like Swiftmailer you'll be sending email via the Amazon SES SMTP interface it requires the SMTP credentials, not the AWS access keys.

    This SMTP credentials are generated from the SMTP settings in the SES console and those are the right ones that should be used when using SMTP to send email with amazon SES.

    Check this documentation http://docs.aws.amazon.com/ses/latest/DeveloperGuide/using-credentials.html