Issue
I am using Laravel 5.8 and I am trying to send email from system using below setting. when is send email one by one its working fine but when I send bunch of marketing email together it stopped after sending 20 email and giving me below error.
I am using below setting in .env.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=my user name
MAIL_PASSWORD=my gmail app password
I am getting below error after sending 20 emails
Expected response code 354 but got code "503", with message "503 5.5.1 RCPT first. w15sm3670747wrs.80 - gsmtp "
also I tried with TLS but it's giving me same error after 20 emails...
Solution
All email senders have a limit of how many emails can be sent in a particular second. Amazon's SES, for example, has limit of 40 emails per second.
I am using this logic to solve this issue:
$count = 0;
foreach ($users as $user) {
$count++;
$user->notify(
(new Notification($emailBody))
->delay(intdiv($count,30))
);
}
Answered By - Jigar
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.