I am using Laravel 5.3, EC2 and SES to send emails.
config/mail.php
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
.env has
MAIL_DRIVER=ses
MAIL_HOST=email-smtp.us-west-2.amazonaws.com
MAIL_PORT=25
MAIL_ENCRYPTION=TLS
SES_KEY='AKIA------DZQ5TYQ'
SES_SECRET=AhN8d----------------ZbBq7TNBmhNnosfYbasg6Q
SES_REGION='us-west-2'
composer.json
"require": {
"aws/aws-sdk-php": "~3.0",
}
EC2 is hosted in Mumbai and SES in us-west. I have tried the following :
1) Creating new IAM user and using the new key/secret.
2) Creating root user key/secret.
3) Running NTPDATE command.
4) php artisan cache:clear , config:clear, view:clear, dump-autoload
5) I also used sparkpost in .env and that gives error 403:forbidden too.
I am still seeing the following error :
[2017-05-26 06:02:00] local.ERROR: exception 'Aws\Ses\Exception\SesException' with message 'Error executing "SendRawEmail" on "https://email.us-west-2.amazonaws.com"; AWS HTTP error: Client error: `POST https://email.us-west-2.amazonaws.com` resulted in a `403 Forbidden` response:
<ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
<Error>
<Type>Sender</Type>
<Code>SignatureDo (truncated...)
SignatureDoesNotMatch (client): The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
Full error here : https://pastebin.com/KSJinB1E
I am not familiar with Laravel to begin with. However, if you are using SMTP, you need to specify MAIL_USERNAME
and MAIL_PASSWORD
. Also the driver should be SMTP
and not SES
since you are using SMTP host of SES.
The documentation link - http://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html should provide you with ways to generate SMTP credentials which are different from your AWS IAM credentials.
In short, you are not using SES SDK but SMTP to send emails. So SES_KEY and SES_SECRET won't do.
I was using the 'ses' MAIL_DRIVER
in laravel too and had the exact same problem as the OP. The issue for me was the IAM user I was using - I used the one that the SES wizard created for me which worked for a while, but then stopped. All I had to do to fix it, was create a new 'Programmatic access' IAM user with the "ses:SendRawEmail"
permission and emails started flowing.
1) check your server or local machine's "Date & time" up to date or not.
2) check config/mail.php with below
'driver' => env('MAIL_DRIVER', 'ses'),
'host' => env('MAIL_HOST'),
'port' => env('MAIL_PORT', 587),
'encryption'=> env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
3) check your .env file with below
MAIL_DRIVER=ses
MAIL_HOST=email-smtp.us-east-1.amazonaws.com
MAIL_PORT=587
MAIL_USERNAME=[your AMI KEY]
MAIL_PASSWORD=[your AMI SECRET]
MAIL_ENCRYPTION=tls
4) check your Config/Services.php file with below
'ses' => [
'key' => env('MAIL_USERNAME'),
'secret' => env('MAIL_PASSWORD'),
'region' => 'us-east-1',// change to your AWS region
],
Don't use amazon ses smtp credentials as MAIL_USERNAME & MAIL_PASSWORD
You don't need SMTP username/password, just using IAM key and secret should get u login SES in Laravel...
You seems put necessary quotation marks in key and region, they should be:
SES_KEY=AKIA------DZQ5TYQ
SES_SECRET=AhN8d----------------ZbBq7TNBmhNnosfYbasg6Q
SES_REGION=us-west-2
If that's not the case, make sure your IAM user has SES write permission: