Skip to content

Fixed sendmail transport blocking HTTP requests#624

Merged
fballiano merged 2 commits intomainfrom
fix/sendmail-blocking-transport
Mar 5, 2026
Merged

Fixed sendmail transport blocking HTTP requests#624
fballiano merged 2 commits intomainfrom
fix/sendmail-blocking-transport

Conversation

@fballiano
Copy link
Contributor

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://default DSN invokes sendmail with the -bs flag, 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_Sendmail used PHP's mail() function, which invokes sendmail via php.ini's sendmail_path (typically /usr/sbin/sendmail -t -i). In -t mode, sendmail accepts the message into its local spool and returns immediately — delivery happens asynchronously in the background.

Solution

Changed the sendmail DSN from sendmail://default to native://default.

Symfony's native://default transport reads sendmail_path from php.ini and passes it directly to SendmailTransport. Since php.ini typically configures sendmail with -t mode, this restores the non-blocking behavior that OpenMage had.

Why -t vs -bs matters

Flag Mode Behavior
-bs Interactive SMTP Opens a full SMTP conversation (EHLO → MAIL FROM → RCPT TO → DATA → QUIT), blocks until MTA processes the message
-t Pipe/stdin Reads recipients from headers, accepts message into local spool, returns immediately

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).
@fballiano fballiano merged commit 37dc8ca into main Mar 5, 2026
24 checks passed
@fballiano fballiano deleted the fix/sendmail-blocking-transport branch March 5, 2026 14:16
@fballiano fballiano added this to the 26.3.0 milestone Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant