Description
Symfony version(s) affected
7.0.6, 6.4.6, 5.4.38
Description
Due to bugfix #54239 the sendmail transport is now throwing an unnecessary exception on messenger worker exit when used in combination with the -bs
option (which is the default), where the sendmail process stream is actually being wrapped with an SMTP transport instance.
This option causes Exim to accept one or more messages by reading SMTP commands on the standard input, and producing SMTP replies on the standard output. SMTP policy controls, as defined in ACLs are applied. Some user agents use this interface as a way of passing locally-generated messages to the MTA.
When used together with the SMTP transport the sendmail process is kept running in the background, and will at some time (depending on server configuration, default 5 minutes for Exim) output an SMTP command timeout. This is normally handled by the SMTP transport when a new message needs to be send, which automatically restarts the transport when necessary (although I haven't been able to verify what happens with the #54239). Instead, it will trigger an exception on worker exit for something that is not necessary.
How to reproduce
- Send an email with a worker using the Sendmail transport
- Wait until timeout is logged by Exim
- Stop the worker and see the exception being logged
Possible Solution
Wrapping the terminate lines for the embedded streams might be enough, but might also have unintended side effects I am not aware of as the stream is a common process stream.
Additional Context
Messenger log:
Apr 09 10:58:27 webdev83 php[7303]: 10:58:27 INFO [messenger] Stopping worker. ["transport_names" => ["async"]]
Apr 09 10:58:27 webdev83 php[7303]: 10:58:27 INFO [messenger] Worker stopped due to time limit of 3600s exceeded ["timeLimit" => 3600]
Apr 09 10:58:28 webdev83 php[7303]: Symfony\Component\Mailer\Exception\TransportException {#896
Apr 09 10:58:28 webdev83 php[7303]: #message: "Process failed with exit code 1: 421 hostname.dev: SMTP command timeout - closing connection\r\n"
Apr 09 10:58:28 webdev83 php[7303]: #code: 0
Apr 09 10:58:28 webdev83 php[7303]: #file: "/var/www/project/vendor/symfony/mailer/Transport/Smtp/Stream/ProcessStream.php"
Apr 09 10:58:28 webdev83 php[7303]: #line: 60
Apr 09 10:58:28 webdev83 php[7303]: -debug: ""
Apr 09 10:58:28 webdev83 php[7303]: trace: {
Apr 09 10:58:28 webdev83 php[7303]: /var/www/project/vendor/symfony/mailer/Transport/Smtp/Stream/ProcessStream.php:60 { …}
Apr 09 10:58:28 webdev83 php[7303]: /var/www/project/vendor/symfony/mailer/Transport/Smtp/SmtpTransport.php:303 { …}
Apr 09 10:58:28 webdev83 php[7303]: /var/www/project/vendor/symfony/mailer/Transport/Smtp/SmtpTransport.php:390 { …}
Apr 09 10:58:28 webdev83 php[7303]: Symfony\Component\Mailer\Transport\Smtp\SmtpTransport->__destruct() {}
Apr 09 10:58:28 webdev83 php[7303]: }
Apr 09 10:58:28 webdev83 php[7303]: }
Exim log:
2024-04-09 10:14:01 1ru6cD-0002Jy-1e <= email@somewhere.nl U=www-data P=local-smtp S=953 id=9c6306db5ac4e3d3d2ab7a7fed5bb55d@somewhere.nl
2024-04-09 10:14:05 1ru6cD-0002Jy-1e Completed
2024-04-09 10:19:01 SMTP command timeout on connection from www-data