0

When sending a mail in my Laravel project using ses as mail provider I am getting a 504 Gateway Time-out after waiting a while. I tried sending mails by using:

Mail::to($session->email)->send(new SessionRegistered($session));

and

Mail::send('emails.sessions', ['firstname' => $request->get('register_first_name'), 'lastname' => $request->get('register_last_name'), 'selected' => $selected], function ($m) use ($request) {
    $m->from(env('MAIL_FROM'), env('MAIL_FROM_NAME'));

    $m->to($request->get('register_email'), $request->get('register_first_name') . ' ' . $request->get('register_last_name'))->subject('Uw persoonlijke programma');
});

When I use log as mail provider everything works. It occurs on my Homestead environment and on our servers. The SES credentials are also used in another project where they are working.

I'm getting the following error:

*502 upstream timed out (110: Connection timed out) while reading response header from upstream
Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Bart Bergmans
  • 4,061
  • 3
  • 28
  • 56

2 Answers2

0

Do you have a load balancer in place? Tried this?

Solution 1: Monitor the HTTPCode_ELB_5XX and Latency metrics. If there is an increase in these metrics, it could be due to the application not responding within the idle timeout period. For details about the requests that are timing out, enable access logs on the load balancer and review the 504 response codes in the logs that are generated by Elastic Load Balancing. If necessary, you can increase your capacity or increase the configured idle timeout so that lengthy operations (such as uploading a large file) can complete. https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/ts-elb-error-message.html

One thing you can do to make it efficient and fault tolerant is by making use of the queues. you can push a task (such as sending an email) into a queue. suppose if the task fails, the queue itself will try again, and it can be customized as well (eg: no of retries)

Another SO Answer

Shobi
  • 10,374
  • 6
  • 46
  • 82
0

Fixed it, I'm an idiot. I used eu-central-1. eu-central-1 doesn't have SES, eu-west-1 does.

Bart Bergmans
  • 4,061
  • 3
  • 28
  • 56