[Mailer] Fix sendmail transport not handling failure #54239
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I found out that the Mailer component
SendmailTransport
does not detect all failures. TheProcessStream
checks stderr when the process is started, but it does not check the exit code and output afterwards. This could lead to silent failures.We found this out due to having
sendmail_path = "/usr/bin/msmtp -t --read-envelope-from"
inphp.ini
, butmsmtp
does not like--read-envelope-from
in combination with the-f
option added by Symfony Mailer. In this case,msmtp
fails with exit status 64 and a message on stdout (rather than stderr). The latter is the reason why I also added the stdout output to the error message (along with the stderr output).Feel free to modify this PR to bring it more in line with existing standards and conventions. The most important part to me is that a failure like this is detected and the mailer does not silently fail.