Open rch77 opened 1 year ago
Hey, thanks for your report! There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?
Yes it's still relevant. The patch is still required to send larger amount of mail. The similar issue is with mailer/Transport/Smtp/SmtpTransport.php but the leak much smaller.
Please send the patch as a PR it would gain more visibility.
Hey, thanks for your report! There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?
Friendly ping? Should this still be open? I will close if I don't hear anything.
It's still relevant
Symfony version(s) affected
6.2 and other 6.*
Description
Trying to send a lot of Laravel 10 email notifications in loop, Sendmail transport runs out of memory: Allowed memory size of 5242880000 bytes exhausted (tried to allocate 2673869000 bytes)
at vendor/symfony/mailer/Transport/Smtp/Stream/AbstractStream.php:37 33▕ public function write(string $bytes, bool $debug = true): void 34▕ { 35▕ if ($debug) { 36▕ foreach (explode("\n", trim($bytes)) as $line) { ➜ 37▕ $this->debug .= sprintf("> %s\n", $line); 38▕ } 39▕ } 40▕ 41▕ $bytesToWrite = \strlen($bytes);
It seems the issue comes from vendor/symfony/mailer/Transport/SendmailTransport.php attempting to store in memory whole mail bodies as debugging information and not even clearing it when called in loop. E.g. SmtpTransport.php doesn't store the whole mail body in memory. I don't think production framework should do either by default.
How to reproduce
Call $user->notify($notification); in loop where notification uses MailMessage with /usr/sbin/sendmail -t -i -odq mailer.
Possible Solution
vendor/symfony/mailer/Transport/SendmailTransport.php @@ -113,7 +113,7 @@ $this->stream->setCommand($command); $this->stream->initialize(); foreach ($chunks as $chunk) {
Additional Context
No response