# Send email via AWS SES in Laravel

1. Apply for AWS SES (simple email service)
2. Create an user, and SES full accessible policy, along with the access key and secret key.
3. Go to AWS console, click email address option on left side, and verify your email.

1. Go to AWS support center to submit a service limit increase case, and choose SES Sending Limits, called ‘Remove it out of SandBox’ Otherwise the capacity of the mail you are allowed to send and its rate will be limited to a large extend, besides that, all of the recipients will have to be verified by SES.

1. Create a Laravel Project
2. Install mail package composer require guzzlehttp/guzzle
3. Install AWS SDK composer require aws/aws-sdk-php
4. Go to config/mail.php, and revise the driver toses
5. Go to config/services.php, and config it as follows:

6. You should config all above mentioned in your .env file as follows:

7. Create class，php artisan make:mail OrderCreated --markdown=emails.orders.created

8. Go to OrderCreated.php, config your build as follows:

9. Go to created.blade.php to customize the view as follows:

10. Now you could use mail to send email wherever you want.

11. Now it should work

12. Do you think “that’s it?”, yeah almost. However, there is one more thing.
I spent one day figuring out all above mentioned, and then I came across something tricky, and it took me one another day.
As a backend programmer, whenever I need to connect a third party payment service, I use ngrok to help me develop.
It’s so weird this time. I made my script to do some things in my controller after I received the response from payment service. However, it did every function I wrote except for the mail function… and here is the error message:

1000 lines omitted.

After tormenting debugging, I found out if I used valet share, this error would not occur, and if I used php artisan serve --port=yourPort, and then ngrok http yourPort, and the error came out.

although I solved the error eventually, to be honest I still didn’t know why..

If you know why the error occurred, kindly drop me a message or a mail, it will really help!