How-To: Sending AWS SES email in Laravel - Success

These would be my record after spending a lot of time testing with Laravel + Amazon SES.

Here is my setting in `.env`:

MAIL_DRIVER=smtp
MAIL_HOST=email-smtp.ap-southeast-1.amazonaws.com
MAIL_PORT=587
MAIL_USERNAME=A***************A
MAIL_PASSWORD=B***************B
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=noreply@mydomain.com
MAIL_FROM_NAME="My Domain"
MAIL_LOG_CHANNEL=stack

In bullet points style.
  • While it would be useful if you do `composer require aws/aws-sdk-php`, it is actually NOT required.
  • MAIL_DRIVER=smtp: Why it is not "ses" when "ses" is also a valid driver?  Because according to this stackoverflow answer, "you are not using SES SDK but SMTP to send emails".  So the drive is set to "smtp", not "ses"
  • MAIL_HOST: You set this value according to these SES endpoint from Amazon, or getting it from Amazon SES - SMTP settings dashboard, as follow:
  • MAIL_USERNAME/PASSWORD: Referring to these comments in this answer: Your SMTP user name and password are not the same as your AWS access key ID and secret access key. Do not attempt to use your AWS credentials to authenticate yourself against the SMTP endpoint.
  • Therefore you need to create SMTP credentials using this button, instead of setting up another IAM user, as follow:
  • The processing of creating such user is quite similar to creating an IAM user.  At the end you also need to download a .CSV file that contains ACCESS KEY and SECRET.
  • You filled the above info into MAIL_USERNAME and MAIL_PASSWORD
  • MAIL_LOG_CHANNEL: You can refer the array key in "channels" in config/logging.php of your Laravel to choose how to log email info.
  • About config/service.php: When I am trying to make SES works in my site, I came across this file.  But even after updating these value, the SES still did not work.  No error log, and no response.  So I roll back to use SMTP instead.
Hope it helps someone.

Comments

Popular posts from this blog

TCPDF How to show/display Chinese Character?

How to fix fancy box/Easy Fancybox scroll not work in mobile

Wordpress Load balancing: 2 web servers 1 MySQL without any Cloud services