[GH-ISSUE #264] Testing for missing Message-ID fails #173

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

Originally created by @Schrank on GitHub (Mar 11, 2024).
Original GitHub issue: https://github.com/axllent/mailpit/issues/264

Hi! Thanks for offering a tool after mailhog is archived.

I'm from the MageOne project, we are offering patches for Magento 1 which is EOL. A little context, because my question might sound weird.

Magento 1/Zend_Framework doesn't add a Message-Id, when they send an email via sendmail. We fixed that and wrote a test to make sure this works. This test is supposed to run against an unpatched version, so we are sure, the patch does what it should.

Since the update from ddev (which changed mailhog to mailpit) this test is always green, because (and here is my assumption after reading the docs), mailpit always adds a Message-Id. I read, that this is true for SMTP. Technically we don't use SMTP, we use sendmail, but maybe sendmail is using SMTP internally?

My question is: Is mailpit adding a Message-Id for emails send via sendmail and if yes, is there a way not to?

I absolutely think it doesn't make sense to break this behaviour by changing it, so this is no feature request! I would like to fix our test, but if this doesn't work, I guess it is time to remove mailpit for THIS particular test and write a new one :-)

Thanks again for your time building it and reading this!

Originally created by @Schrank on GitHub (Mar 11, 2024). Original GitHub issue: https://github.com/axllent/mailpit/issues/264 Hi! Thanks for offering a tool after mailhog is archived. I'm from the MageOne project, we are offering patches for Magento 1 which is EOL. A little context, because my question might sound weird. Magento 1/Zend_Framework doesn't add a Message-Id, when they send an email via sendmail. We fixed that and wrote a test to make sure this works. This test is supposed to run against an unpatched version, so we are sure, the patch does what it should. Since the update from ddev (which changed mailhog to mailpit) this test is always green, because (and here is my assumption after reading the docs), mailpit always adds a Message-Id. I read, that this is true for SMTP. Technically we don't use SMTP, we use sendmail, but maybe sendmail is using SMTP internally? My question is: Is mailpit adding a Message-Id for emails send via sendmail and if yes, is there a way not to? I absolutely think it doesn't make sense to break this behaviour by changing it, so this is no feature request! I would like to fix our test, but if this doesn't work, I guess it is time to remove mailpit for THIS particular test and write a new one :-) Thanks again for your time building it and reading this!
kerem closed this issue 2026-03-15 13:00:40 +03:00
Author
Owner

@axllent commented on GitHub (Mar 11, 2024):

@Schrank - that is a very good question, and the answer is is a little bit subjective - I'll try explain in the most logical manner.

Firstly it is worth noting that there are a lot of different SMTP servers, sendmail "clones", and thousands of email generation libraries & frameworks - any they all work slightly differently which can make it a bit frustrating at times. They should however all adhere to the email/SMTP standards (and many don't unfortunately, so more popular mail servers also tend to try "correct" common mistakes).

Basically, whilst a mail client/library/framework can provide a Message-Id, it does not need to provide a Message-Id at all. Some mail classes/programs add this field automatically before sending, others do not - again, it is completely optional.

Message-Ids are added automatically by SMTP servers if a message does not already have one, and even in some cases an existing one could even be overwritten by an SMTP server (unusual, but possible). A Message-Id is an required field for SMTP servers to talk to each other, and if mostly used to (internally) identify a message when grouping messages together (eg: a threaded view). Mailpit works in this way too - if it received a message without a Message-Id then it will automatically generate a unique one and append it to the email head. It is even possible/legal (though not advisable) to have multiple emails with the same Message-Id.

To confuse matters, some "sendmail" implementations add a Message-Id if it is missing, but again, this is not required at that level. Your app communicated with sendmail as a command-line "function", but sendmail then communicate with the SMTP server using SMTP. As I mentioned earlier, if the message still does not have a Message-Id when it reaches the SMTP server, then the SMTP server assigns one.

So to get back to your questions, the Magento 1/Zend_Framework does not actually have to provide a Message-Id. There is nothing wrong in doing so, but it's not required as this is added by the SMTP server if it is missing. Any mail captured in Mailpit (as with any any SMTP server) will also always have a Message-Id in the same manner. Does this help?

<!-- gh-comment-id:1989520976 --> @axllent commented on GitHub (Mar 11, 2024): @Schrank - that is a very good question, and the answer is is a little bit subjective - I'll try explain in the most logical manner. Firstly it is worth noting that there are a lot of different SMTP servers, sendmail "clones", and thousands of email generation libraries & frameworks - any they all work slightly differently which can make it a bit frustrating at times. They should however all adhere to the email/SMTP standards (and many don't unfortunately, so more popular mail servers also tend to try "correct" common mistakes). Basically, whilst a mail client/library/framework _can_ provide a `Message-Id`, it does not _need_ to provide a `Message-Id` at all. Some mail classes/programs add this field automatically before sending, others do not - again, it is completely optional. `Message-Ids` are added automatically by SMTP servers if a message does not already have one, and even in some cases an existing one could even be overwritten by an SMTP server (unusual, but possible). A `Message-Id` is an required field for SMTP servers to talk to each other, and if mostly used to (internally) identify a message when grouping messages together (eg: a threaded view). Mailpit works in this way too - if it received a message without a `Message-Id` then it will automatically generate a unique one and append it to the email head. It is even possible/legal (though not advisable) to have multiple emails with the same `Message-Id`. To confuse matters, some "sendmail" implementations add a `Message-Id` if it is missing, but again, this is not required at that level. Your app communicated with sendmail as a command-line "function", but sendmail then communicate with the SMTP server using SMTP. As I mentioned earlier, if the message still does not have a `Message-Id` when it reaches the SMTP server, then the SMTP server assigns one. So to get back to your questions, the Magento 1/Zend_Framework does not actually have to provide a `Message-Id`. There is nothing wrong in doing so, but it's not required as this is added by the SMTP server if it is missing. Any mail captured in Mailpit (as with any any SMTP server) will also always have a `Message-Id` in the same manner. Does this help?
Author
Owner

@Schrank commented on GitHub (Mar 11, 2024):

Wow, thanks for writing this up! That helps a lot! I’ll delete the test and write a unit test 😂 far less systems involved.

again: thanks, learned a lot!

<!-- gh-comment-id:1989537239 --> @Schrank commented on GitHub (Mar 11, 2024): Wow, thanks for writing this up! That helps a lot! I’ll delete the test and write a unit test 😂 far less systems involved. again: thanks, learned a lot!
Author
Owner

@axllent commented on GitHub (Mar 12, 2024):

Not a problem, and glad I could help!

<!-- gh-comment-id:1989689133 --> @axllent commented on GitHub (Mar 12, 2024): Not a problem, and glad I could help!
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#173
No description provided.