sending mail but no message-id

落爺英雄遲暮 提交于 2019-12-07 11:48:16

问题


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!


回答1:


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 := ...';
IdMessage.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:

http://indyproject.org/sockets/blogs/changelog/20160912.aspx

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.




回答2:


It works with Indy9, maybe things haven't cahnged too much in 10:

    procedure AddMsgID(AMsg: TIdMessage);
    var
      id: AnsiString;
    begin
      id := GenerateUniqueMsgID;
      AMsg.MsgId := id;
      AMsg.AddHeader('Message-ID=' + id);
      // AMsg.ExtraHeaders.Values['Message-ID'] := id;
    end; // AddMsgID


来源:https://stackoverflow.com/questions/4496821/sending-mail-but-no-message-id

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!