thitami
thitami

Reputation: 838

Connecting to AWS SES with Laravel

Currently working on a user registration form which (as expected) sends out an email to the registered user.

The client decided to go with AWS SES, so I have already had this configured.

.env

MAIL_DRIVER=smtp
MAIL_HOST=email-smtp.eu-west-1.amazonaws.com
MAIL_PORT=587
MAIL_USERNAME=my_username
MAIL_PASSWORD=my_password
MAIL_ENCRYPTION=null 

Also defined the following credentials:

SES_KEY=keyRetrievedFromMyCredentialsInSES
SES_SECRET=passwordRetrievedFromMyCredentialsInSES

And also telnet email-smtp.eu-west-1.amazonaws.com 587 Trying 52.19.235.197... Connected to ses-smtp-eu-west-1-prod-345515633.eu-west-1.elb.amazonaws.com.

What could have gone wrong here?

Upvotes: 1

Views: 5751

Answers (2)

Dario Vranjković
Dario Vranjković

Reputation: 91

Check documentation -> https://laravel.com/docs/7.x/mail

  1. Install guzzle
    composer require guzzlehttp/guzzle
  1. Install AWS SDK for php (laravel)
    composer require aws/aws-sdk-php
  1. Check values in .env file
MAIL_DRIVER=ses
MAIL_HOST=email-smtp.eu-west-1.amazonaws.com  //aws SMTP Settings -> check mail host
MAIL_PORT=465
MAIL_USERNAME=smpt_username  //aws SMTP Settings -> click Create My SMTP Credentials
MAIL_PASSWORD=smpt_password  //aws SMTP Settings -> click Create My SMTP Credentials
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=your_email  //aws Email Addresses -> add email address -> send test email (in sendbox mode you can send email only on same email for testing) 
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID= aws_access_key_id  //create user or in existing user check access key
AWS_SECRET_ACCESS_KEY= secret_access_key  //create user or in existing user check secret key
AWS_DEFAULT_REGION=eu-west-1  //change with your region
AWS_BUCKET=

  1. In config/service.php
'ses' => [
       'key' => env('AWS_ACCESS_KEY_ID'),
       'secret' => env('AWS_SECRET_ACCESS_KEY'),
       'region' => env('AWS_DEFAULT_REGION', 'eu-west-1'), // change with your region
   ],
  1. Clear cache
php artisan config:cache

Upvotes: 0

Jared Chu
Jared Chu

Reputation: 2862

It may not working without ADDRESS and NAME setting.

MAIL_DRIVER=smtp
MAIL_HOST=null
MAIL_PORT=null
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

MAIL_FROM_ADDRESS = '[email protected]'
MAIL_FROM_NAME = 'Example'

After change setting in .env. Run config:cache:

php artisan config:cache

Upvotes: 1

Related Questions