postmark-dotnet icon indicating copy to clipboard operation
postmark-dotnet copied to clipboard

MailMessage.ReplyToList is ignored while the deprecated ReplyTo property does work

Open frankvaneykelen opened this issue 9 years ago • 3 comments

When I send a MailMessage that has a ReplyTo set I get what I expect: "Reply-To: TentantName [email protected]" in the raw source of the message:

When I send a MailMessage that has the same To, but added to the ReplyToList, there's no Reply-To in the raw source of the message.

I think that this code in SystemMailExtensions.cs:

if (message.ReplyTo != null)
{
    pm.ReplyTo = !string.IsNullOrEmpty(message.ReplyTo.DisplayName)
        ? string.Format("{0} <{1}>", message.ReplyTo.DisplayName, message.ReplyTo.Address)
        : message.ReplyTo.Address;
}

should be extended to support a ReplyToList, also because ReplyTo is deprecated:

ReplyTo is obsoleted for this type. Please use ReplyToList instead which can accept multiple addresses. https://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.replyto(v=vs.110).aspx

frankvaneykelen avatar Aug 07 '15 13:08 frankvaneykelen

The Postmark API currently supports only a single ReplyTo address, and therefore setting a list of reply-to addresses would not be honored by the API.

We could handle ReplyToList, but assert that it only has zero or one address in it, let me give this some thought and reply back later.

If you have an opinion about how you'd like to see this handled, knowing that we support a single ReplyTo, I'd love to get your feedback.

atheken avatar Aug 10 '15 14:08 atheken

I think that handling a ReplyToList while ignoring all but the first address is something that developers would expect. Developers could be warned of it in the wiki (https://github.com/wildbit/postmark-dotnet/wiki/Using-System.Net.Mail.MailMessage):

There are two ways to specify a ReplyTo address:

mailMessage.ReplyTo = new MailAddress("[email protected]", "Some User");

mailMessage.ReplyToList.Add(new MailAddress("[email protected]", "Some User"));

If you use the first method please be aware that because it is deprecated ("ReplyTo is obsoleted for this type. Please use ReplyToList instead which can accept multiple addresses.") you might have to disable the warning:

#pragma warning disable 612, 618
    mailMessage.ReplyTo = new MailAddress("[email protected]", "Some User");
#pragma warning restore 612, 618

If you use the second method please be aware that only the first address in the ReplyToList will be used because the Postmark API only supports a single ReplyTo address !

frankvaneykelen avatar Aug 10 '15 14:08 frankvaneykelen

7 years and still open?

I have the same problem, ReplyToList is ignored, I use:

     msg.ReplyToList.Add(new MailAddress("[email protected]"));

but when I answer to the received email in outlook, the recipient is the sender and not this no-reply address.

emaborsa avatar Dec 01 '22 08:12 emaborsa