Question

Since I upgraded to Indy10, I've noticed that the ReplyTo field (Msg.ReplyTo[0].Address) on received TIdMessage(s) seems to be getting filled in with the address from the Return-path header if an explicit reply to header isn't present. My expectation would be that the Msg.ReplyTo.Count should be zero if there's no reply-to header. What's going on here? Is this a bug? Design change? Something else? How can I tell whether the message has a separate reply-to address, or whether I should be replying to the address from the "from" field? Having it reply to the return-address seems to give a butchered version of my own email, not very useful.

My existing logic (that isn't working for messages with no reply-to address) looks like this:

if Msg.ReplyTo.Count>0 then
  FReplyTo := Msg.ReplyTo[0].Address
else
  FReplyTo := Msg.From.Address;
Was it helpful?

Solution

When parsing an email, TIdMessage.ReplyTo looks at the Reply-To header first, and if empty/missing then looks at the Return-Path header. If you want to know whether Reply-To by itself is blank/missing or not, you will have to look at TIdMessage.Headers.Values['Reply-To'] manually.

Thinking about it more, and doing some research into how Reply-To and Return-Path actually work, it probably makes sense to remove Return-Path from the TIdMessage.ReplyTo property, so I have made that change now.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top