3

I'm running Laravel 5.4.24 and I can't get it to send through Amazon SES SMTP.

However when I download SwiftMailer and run it standalone I can.

Working..

require("vendor/autoload.php"); // Create the Transport $transport = new Swift_SmtpTransport('email-smtp.us-west-2.amazonaws.com', 587, 'tls'); $transport->setUsername('A**************A'); $transport->setPassword('A****************************m'); // Create the Mailer using your created Transport $mailer = new Swift_Mailer($transport); // Create a message $message = new Swift_Message('Wonderful Subject'); $message->setFrom(['noreply@su*****th.com' => 'John Doe']); $message->setTo(['j*******@gmail.com' => 'Jamie']); $message->setBody('Here is the message itself'); // Send the message $result = $mailer->send($message); 

Laravel setup thats not working

MAIL_DRIVER=smtp MAIL_HOST=email-smtp.us-west-2.amazonaws.com MAIL_PORT=587 MAIL_USERNAME=A****************A MAIL_PASSWORD=A************************m MAIL_ENCRYPTION=tls 

Even though the credentials are identical I get

Expected response code 250 but got code "530", with message "530 Authentication required 

I've tried

php artisan queue:restart php artisan config:cache 

This is how I'm using Mail in code

Mail::send('emails.verify', $data, function($message) use ($data) { $message->from('noreply@su*****h.com', "Jamie - ****"); $message->subject("Please verify your email address"); $message->to($data['email']); }); 

But with no luck.

Any ideas?

5
  • I've had problems using .env before, try putting configs directly in config/mail.php Commented Jun 2, 2017 at 16:32
  • don't forget to php artisan config:cache Commented Jun 2, 2017 at 16:33
  • tried both of those already, no luck I'm afraid :-( Commented Jun 2, 2017 at 16:36
  • Are you sure you are using the SES SMTP username and password and not the account access and secret? Commented Jun 2, 2017 at 17:03
  • Yep. Works in swiftmailer standalone but not in laravel, had a few other people check credentials. All looks fine. Odd. Commented Jun 2, 2017 at 17:09

1 Answer 1

2

The SES keys and Region are configured in the config/services.php file.

So for me the issue was that even though I already had my default region set to us-west-2 in my other AWS configs SES uses its own config in the Services file which was set directly to 'us-east-1' and not using the existing AWS keys in my .env file.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.