Laravel email with queue 550 error (too many email

2020-02-06 06:51发布

Our emails are failing to send using Laravel with a Redis Queue.

The code that triggers the error is this: ->onQueue('emails')

$job = (new SendNewEmail($sender, $recipients))->onQueue('emails');
$job_result = $this->dispatch($job);

In combination with this in the job:

use InteractsWithQueue;

Our error message is:

Feb 09 17:15:57 laravel: message repeated 7947 times: [ production.ERROR: exception 'Swift_TransportException' with message 'Expected response code 354 but got code "550", with message "550 5.7.0 Requested action not taken: too many emails per second "' in /home/laravel/app/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:383 Stack trace: #0 /home/laravel/app/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(281): 

Our error only happens using Sendgrid and not Mailtrap, which spoofs emailing sending. I've talked with Sendgrid and the emails never touched their servers and their service was fully active when my error occurred. So, the error appears to be on my end.

Any thoughts?

8条回答
家丑人穷心不美
2楼-- · 2020-02-06 07:31

I used sleep(5) to wait five seconds before using mailtrap again.

foreach ($this->suscriptores as $suscriptor)  {
    \Mail::to($suscriptor->email)
           ->send(new BoletinMail($suscriptor, $sermones, $entradas));
    sleep(5);
}

I used the sleep(5) inside a foreach. The foreach traverses all emails stored in the database and the sleep(5) halts the loop for five seconds before continue with the next email.

查看更多
戒情不戒烟
3楼-- · 2020-02-06 07:35

Seems like only Mailtrap sends this error, so either open another account or upgrade to a paid plan.

查看更多
登录 后发表回答