Sending email using smtp and setting the message-id

19,603

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.

Share:
19,603
Kunal
Author by

Kunal

Updated on June 04, 2022

Comments

  • Kunal
    Kunal almost 2 years

    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 "[email protected]". Now I want to send mail to "[email protected]". So client set message-id as "[email protected]" 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
    Kunal about 13 years
    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?
  • james.garriss
    james.garriss over 11 years
    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.
  • Henry
    Henry almost 11 years
    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.
  • Quolonel Questions
    Quolonel Questions over 9 years
    Everything stated herein is false.
  • Bridge
    Bridge over 6 years
    I have absolutely seen the Message-ID overwritten.
  • PeeHaa
    PeeHaa over 4 years
    "In your case your smtp client acts as the originating server" No, it is not. It's an client sending an smtp message to a server (which in turn will handle the further transport). As such this answer is completely wrong.