delphiindyindy10

sending mail but no message-id


I am getting interesting rejections from my clients mail server when sending a mail with indy-10's tidMessage component saying:

550 Rejected: Message does not contain a Message-ID

I get this even when using indy's own demo app

http://www.indyproject.org/DemoDownloads/Indy_10_MailClient.zip

what do I do to fix this. thanks!


Solution

  • TIdMessage in Indy 10 intentionally omits the 'Message-Id' header when encoding an email to a socket or TStream. You will have to use the TIdMessage.ExtraHeaders property, eg:

    IdMessage1.MsgId := '...';
    IdMessage1.ExtraHeaders.Values['Message-Id'] := IdMessage1.MsgId;
    

    EDIT:

    As a followup for this - TIdMessage has now been updated with logic changes in how it handles the "Message-ID" and "In-Reply-To" headers:

    https://www.indyproject.org/2016/09/12/logic-changes-in-tidmessage-regarding-message-id-and-in-reply-to-headers/

    The TIdMessage.MsgId property now generates a "Message-ID" header regardless of whether the email is being saved, streamed, or transmitted. So you do not need to use the ExtraHeaders property anymore.