f3-mailer icon indicating copy to clipboard operation
f3-mailer copied to clipboard

Too many open connections

Open YoeriNijs opened this issue 9 months ago • 3 comments

The mail plugin causes problems when sending emails in bulk. I use AWS SES and have already adjusted the limits, so AWS should not throw any errors here. However, I still receive smtp errors. It seems that the open connections are not being closed properly.

The error I get: SMTP dialog error: 421 Throttling failure: Too many open connection from Account. Try again later.

I call the F3 mailer by creating an instance and send a mail for every recipient, by doing so:

foreach($recipients as $r) {
   $mailer = new Mailer();
   $mailer->addTo($recipient, null);
   ...
   $mailer->send();
}

The number of recipients in my case is +/- 400. I suspect F3 is not closing the connection properly, but just want to make sure it is not the F3 mailer as well.

YoeriNijs avatar May 09 '24 08:05 YoeriNijs

You would need to dive deeper into debugging and check whether similar commands are being executed - referring to "quit" and eventually "close" from PHP Mailer .

https://github.com/PHPMailer/PHPMailer/blob/829def33886c827e1622f965a8813d7bf453f15a/src/SMTP.php#L936

https://github.com/PHPMailer/PHPMailer/blob/829def33886c827e1622f965a8813d7bf453f15a/src/SMTP.php#L705

slavino avatar May 09 '24 13:05 slavino

According to the stacktrace, the real problem is in F3's SMTP handler:

Wed, 08 May 2024 10:01:27 +0200 [x.x.x.x] <url />: 256, 500: SMTP dialog error: 421 Throttling failure: Too many open connection from Account. Try again later.

Wed, 08 May 2024 10:01:27 +0200 [x.x.x.x] ([/var/www/html/vendor/bcosca/fatfree-core/smtp.php:162] [/var/www/html/vendor/bcosca/fatfree-core/smtp.php:237] SMTP->dialog() [/

So, if I understand correctly, if the SMTP return code is not 235, it should send the QUIT dialog and also close the socket connection. It seems that some conditions are not met when we loop for multiple recipients?

YoeriNijs avatar May 09 '24 18:05 YoeriNijs

Fyi: made the migration to PHPMailer and now the issue is resolved (also by closing the connection after every call).

YoeriNijs avatar May 18 '24 17:05 YoeriNijs