7

I have a client which sends email using the smtp protocol. The client can be configured against any mail server which supports smtp (for example: gmail, yahoo).

Now, while sending the mail from client, I am setting the "message-id" in the header. Now, my question is does mail server guarantees that the message id set by me in the header will "not" be reset (or replaced) by the mail server, before actual forwarding the mail.

For example: Let say my client is configured against "abc@gmail.com". Now I want to send mail to "abc2@yahoo.com". So client set message-id as "message123456644@abc.gmal.com" and send the mail using smtp.

So, now when gmail sends this message to yahoo, does it guarantee that my message-id will be retained.

Thanks Kunal

Kunal
  • 151
  • 1
  • 2
  • 6

3 Answers3

7

The Message-ID is a unique string assigned by the mail system when the message is first created. This is also forgeable in most cases, but requires a little more specialized knowledge than forging the From: line. Also, the Message-ID: often identifies the system from which the sender is logged in, rather than the actual system where the message originated.

Long story short: Your client can set it, but there is not guarantee it will remain that way.

Brady Moritz
  • 8,624
  • 8
  • 66
  • 100
Jim
  • 809
  • 1
  • 7
  • 18
1

Message ID is used to understand the originating server of the message. Technically this is set by the first message server that handles your message. Once set this is not meddled by subsequent server. In your case your smtp client acts as the originating server and the server will not meddle with it.

(What are you doing with message id anyways.)

uncaught_exceptions
  • 21,712
  • 4
  • 41
  • 48
  • Thanks, I want to keep the message Id, so that I can later correlate this mail with the later incoming mail (using "in-rely-to" header). I will persist this messageId with me at the client. Then my client also do have a POP3 protocol implemented which pull the mails from the mail server. I will then use the persisted messageId to compare it with the "in-reply-to" header of the incoming mail to correlate the mail. So, if the mail servers changes the messageId, there will be no way to correlate them. Is there any good way of doing it then? – Kunal Apr 06 '11 at 05:11
  • Since your ISP's SMTP server will (most likely) create this ID for you, why not just use what it creates? This is how email clients today manage threads/conversations. – james.garriss Nov 06 '12 at 16:33
  • You can try Gmail's approach: It attempts to groups messages according to the trimmed subject (removal of RE:/FW: etc) as long as a Reference / In-reply-to header is set on the subsequent emails, even if those header(s) contain bogus values. – Henry May 20 '13 at 20:45
  • 4
    Everything stated herein is false. – Quolonel Questions Oct 16 '14 at 10:41
  • 1
    I have absolutely seen the Message-ID overwritten. – Bridge Jan 19 '18 at 17:03
0

you can't count on headers (including the Message ID) not being changed, although you CAN check to see if the Message ID matches other mail already in the client's inbox and if it does, you're good to go. But you can put another ID in the body of the message itself, such as at the bottom. Any replies that do not delete that string can be related to their origins. Still not perfect, but gives another shot at a match-up. You can also attempt Subject line matchups, but of course short and common subject lines (especially once RE: and FWD: and such are removed) can make that method extremely faulty. In the end you can't build a threaded email system that relies on other mail servers that are not in your control.

TheSatinKnight
  • 696
  • 7
  • 16