[GH-ISSUE #421] Regression: Can no longer send To: headers with addresse names #271

Closed
opened 2026-03-15 13:34:59 +03:00 by kerem · 2 comments
Owner

Originally created by @navarr on GitHub (Jan 8, 2025).
Original GitHub issue: https://github.com/axllent/mailpit/issues/421

From: wardenenv/warden#830

When sending SMTP emails to Mailpit where the From address is in Display Name <user@hostname> format (or "Display Name" <user@hostname> format, the email now fails to send.

2025/01/08 14:48:54 501 5.5.4 Syntax error in parameters or arguments (invalid TO parameter)

Such format complies with RFC 2822 Address Format

I believe this may be a regression from #409

Originally created by @navarr on GitHub (Jan 8, 2025). Original GitHub issue: https://github.com/axllent/mailpit/issues/421 From: wardenenv/warden#830 When sending SMTP emails to Mailpit where the From address is in `Display Name <user@hostname>` format (or `"Display Name" <user@hostname>` format, the email now fails to send. 2025/01/08 14:48:54 501 5.5.4 Syntax error in parameters or arguments (invalid TO parameter) Such format complies with [RFC 2822 Address Format](https://datatracker.ietf.org/doc/html/rfc2822#section-3.4) I believe this may be a regression from #409
kerem closed this issue 2026-03-15 13:35:04 +03:00
Author
Owner

@axllent commented on GitHub (Jan 8, 2025):

Potentially yes, but I'm not sure it's a bug in Mailpit but rather that it is more RFC compliant in the SMTP transactions. What changed in Mailpit is how it validates the SMTP transaction's RCPT TO: command, which is typically sent from sendmail to Mailpit.

The first thing that stands out to me is the syntax being used here in the PHP mail() command. The first parameter ($to) should be just an email address (or comma-separated email addresses), not the full Name <email> syntax. Nowhere could I find any examples of the name & email being used. The documentation is a bit vague though. I suspect that whatever sendmail implementation you are using is just using this string 1:1 for the RCPT TO: value, for instance RCPT TO:<Test <me@navarr.me>> which is incorrect and non-RFC compliant. The only way to know for sure is to run Mailpit in verbose mode (eg: mailpit -v), however I don't know how it's implemented in warden. If you are able to, could you please configure the mailpit server to run with -v and then check the logs which will show you what is being transmitted when running mail('Test <me@navarr.me>','Test Subject','Test Message',"From: me@navarr.me\r\n");?

Secondly, I'm not able to replicate this locally, however I am using Mailpit's sendmail implementation which is far more forgiving - I don't know how warden's PHP sendmail_path is configured. Could you please shed some light on what sendmail implementation is being used by PHP to send to Mailpit?

<!-- gh-comment-id:2578738930 --> @axllent commented on GitHub (Jan 8, 2025): Potentially yes, but I'm not sure it's a bug in Mailpit but rather that it is more RFC compliant in the SMTP transactions. What changed in Mailpit is how it validates the SMTP transaction's `RCPT TO:` command, which is typically sent from `sendmail` to Mailpit. The first thing that stands out to me is the [syntax being used](https://github.com/wardenenv/warden/issues/830#issuecomment-2577844131) here in the PHP `mail()` [command](https://www.php.net/manual/en/function.mail.php). The first parameter (`$to`) should be just an email address (or comma-separated email addresses), not the full `Name <email>` syntax. Nowhere could I find any examples of the name & email being used. The documentation is a bit vague though. I _suspect_ that whatever sendmail implementation you are using is just using this string 1:1 for the `RCPT TO:` value, for instance `RCPT TO:<Test <me@navarr.me>>` which is incorrect and non-RFC compliant. The only way to know for sure is to run Mailpit in verbose mode (eg: `mailpit -v`), however I don't know how it's implemented in warden. If you are able to, could you please configure the mailpit server to run with `-v` and then check the logs which will show you what is being transmitted when running `mail('Test <me@navarr.me>','Test Subject','Test Message',"From: me@navarr.me\r\n");`? Secondly, I'm not able to replicate this locally, however I am using Mailpit's sendmail implementation which is far more forgiving - I don't know how warden's PHP `sendmail_path` is configured. Could you please shed some light on what sendmail implementation is being used by PHP to send to Mailpit?
Author
Owner

@navarr commented on GitHub (Jan 9, 2025):

Thank you @axllent for your in-depth response! I was able to confirm what you anticipated; which was that the sendmail program Warden was using was sending the To as-is to Mailpit. I have converted Warden from its current sendmail to using the Mailpit sendmail program and this solves the issue for PHP users who expect to be able to send To addresses in such a maner.

For reference, the sendmail program Warden was using was Mailhog's sendmail program. (We had accepted a PR to swap out Mailhog for Mailpit, but the sendmail program was left alone as it was working without issue).

<!-- gh-comment-id:2580849484 --> @navarr commented on GitHub (Jan 9, 2025): Thank you @axllent for your in-depth response! I was able to confirm what you anticipated; which was that the sendmail program Warden was using was sending the To as-is to Mailpit. I have converted Warden from its current sendmail to using the Mailpit sendmail program and this solves the issue for PHP users who expect to be able to send To addresses in such a maner. For reference, the sendmail program Warden _was_ using was Mailhog's sendmail program. (We had accepted a PR to swap out Mailhog for Mailpit, but the sendmail program was left alone as it was working without issue).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/mailpit#271
No description provided.