6

My controller which is suitable for sending emails looks like this:

class MailerController extends AbstractController
{
    /**
     * @Route("/email")
     */
    public function sendEmail(MailerInterface $mailer): Response
    {
        $email = (new Email())
            ->from('hello@example.com')
            ->to('you@example.com')
            ->subject('Time for Symfony Mailer!')
            ->text('Sending emails is fun again!')

        $mailer->send($email);

        // ...
    }
}

After visiting /email I am getting the following error:

Failed to authenticate on SMTP server with username "XXX" using the following authenticators: "LOGIN", "PLAIN". Authenticator "LOGIN" returned "Symfony\Component\Mailer\Exception\TransportException: Expected response code "235" but got code "535", with message "535 Authentication Credentials Invalid"

My mailer config looks like this:

framework:
    mailer:
        dsn: 'smtp://XXX:YYY@email-smtp.eu-central-1.amazonaws.com:465'

I would like to add that I XXX and YYY are AWS credentials obtained from here

dosad
  • 151
  • 7

1 Answers1

3

You can fix it by installing a new lib composer require symfony/amazon-mailer and use ses+api

But make sure to urlencode any special characters that you have in your secret key.

Example:

ses+smtp://$AWS_MAILER_USER:$WS_MAILER_PASSWORD@default?region=eu-west-1

Another option is trying with async-aws/ses package.

  • After applying your changes I am getting the error: `Could not reach the remote Amazon server.`. I am using `symfony/amazon-mailer: 4.4.*`, maybe I should add in `dsn` string some info about port or url to smpt server – dosad Sep 08 '21 at 06:13
  • 1
    And why I cannot use plain smtp protocol? – dosad Sep 08 '21 at 06:24