1
votes

I'm trying to send an email in Laravel using Amazon SES driver but keep getting this error:

"local.ERROR: exception 'Swift_TransportException' with message 'Expected response code 250 but got code "530", with message "530 Authentication required "' in /***/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:383"

in mail.php the driver is 'ses', in services I've set up the key, secret and region. Also checked .env to make all the data match, but still getting this error. I know that is not on the Amazon side because we have that very same account sending emails in another script, so I'm sure it's some wrong configuration in Laravel, I just don't know where else to look... help?

3
I was able to make it work with PHPMailer in laravel, but im curious about how to use the default methods from laravel...Ale Van Houtte
ok, first error was to use the amazon smtp endpoint with the APIAle Van Houtte
Ok, after a lot of digging, I manage to try to check credentials with amazon, but got rejected. Good thing is that in the way to rejection I learn a few things. First what i already mentioned about smtp endpoint, second, the credentials go in the root of the computer, not the project or site (don't get confuse with ~ which is the home of the current user) so the code I used to check this was: $s3 = new S3Client([ 'profile' => 'default', 'version' => 'latest', 'region' => 'eu-west-1' ]); $result = $s3->listBuckets(); var_dump($result);Ale Van Houtte
last error says SignatureDoesNotMatch (client): The request signature we calculated does not match the signature you provided. Check your key and signing method. Ale Van Houtte
at the end, the service wasn't active, so that's my manager fault! but i managed to make it work! :PAle Van Houtte

3 Answers

1
votes

Have you added all needed configurations?

.env file:

MAIL_DRIVER=smtp
MAIL_HOST=email-smtp.eu-west-1.amazonaws.com
MAIL_PORT=587
MAIL_USERNAME=**********USERNAME**********
MAIL_PASSWORD=**********PASSWORD**********
MAIL_ENCRYPTION=tls

At least, such configuration works with Laravel 5.1

0
votes

Check the config/mail.php

return [
    'driver' => env('MAIL_DRIVER', 'ses'),
    'host' => env('MAIL_HOST', ''),
    'port' => env('MAIL_PORT', 587),
    'from' => ['address' => null, 'name' => null],
    'encryption' => env('MAIL_ENCRYPTION', 'tls'),
    'username' => env('MAIL_USERNAME', ''),
    'password' => env('MAIL_PASSWORD', ''),
    'sendmail' => '/usr/sbin/sendmail -bs',
];

Make sure the .env file has the following

MAIL_DRIVER=smtp
MAIL_HOST=email-smtp.eu-west-1.amazonaws.com // hosting site
MAIL_PORT=587
MAIL_USERNAME=your username
MAIL_PASSWORD=your password
MAIL_ENCRYPTION=tls

Also clear the config cache

php artisan config:cache
0
votes

Laravel 8, AWS 3.178 for aws/aws-sdk-php

.env should look like this

#MAIL_MAILER=smtp
#MAIL_HOST=mailhog
#MAIL_PORT=1025
#MAIL_USERNAME=null
#MAIL_PASSWORD=null
#MAIL_ENCRYPTION=null
#MAIL_FROM_ADDRESS=null
#MAIL_FROM_NAME="${APP_NAME}"

MAIL_MAILER=ses
MAIL_HOST=email-smtp.ap-southeast-1.amazonaws.com
MAIL_PORT=587
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls

AWS_ACCESS_KEY_ID=yourkey
AWS_SECRET_ACCESS_KEY=yoursecreaccesskey
AWS_DEFAULT_REGION=ap-southeast-1
AWS_BUCKET=

Notice the first line is not MAIL_DRIVER=ses but it should be MAIL_MAILER=ses