Fixed sendmail transport blocking HTTP requests#624
Merged
Conversation
Changed the sendmail DSN from sendmail://default to native://default. Symfony sendmail://default uses the -bs flag by default, which opens an interactive SMTP session with the local MTA and waits for it to fully process/relay the message before returning. If the MTA performs synchronous DNS lookups or remote delivery, this blocks the entire HTTP request. Symfony native://default reads sendmail_path from php.ini (typically /usr/sbin/sendmail -t -i), which uses -t mode: sendmail accepts the message into its local spool and returns immediately, handling delivery asynchronously in the background. This matches the behavior of OpenMage/Magento 1 which used Zend_Mail sendmail transport (backed by PHP mail() function, which also uses php.ini sendmail_path).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
When using the default sendmail transport, transactional emails (customer registration, password reset, etc.) block the entire HTTP request, causing the page to hang until the email is fully delivered.
This happens because Symfony's
sendmail://defaultDSN invokes sendmail with the-bsflag, which opens an interactive SMTP session with the local MTA. The MTA then performs synchronous operations (DNS lookups, connecting to remote MX servers, relaying) before returning control — blocking the PHP process for the entire duration.In OpenMage/Magento 1 this was never a problem because
Zend_Mail_Transport_Sendmailused PHP'smail()function, which invokes sendmail via php.ini'ssendmail_path(typically/usr/sbin/sendmail -t -i). In-tmode, sendmail accepts the message into its local spool and returns immediately — delivery happens asynchronously in the background.Solution
Changed the sendmail DSN from
sendmail://defaulttonative://default.Symfony's
native://defaulttransport readssendmail_pathfrom php.ini and passes it directly toSendmailTransport. Since php.ini typically configures sendmail with-tmode, this restores the non-blocking behavior that OpenMage had.Why
-tvs-bsmatters-bs-t