I am using System.Net.Mail
email. in the code i am setting the return-path of email as follow:
string sReturnPath = ConfigurationManager.AppSettings["ReturnPath"].ToString();
if (sReturnPath.Length > 0) {
msg.Headers.Add("Return-Path", sReturnPath);
}
If the delivery has failed it should go to return-path but it doesn't, even though I can see the header of email's return-path being from config file that I specified. The email gets returned to sender.
any ideas?
You're using a slightly wrong approach. Simple Mail Transfer Protocol (RFC 2821) says:
If you want your message to be returned to the address other than the one specified in the
From:
field, then the address should be set in the SMTP message envelope rather than in the message header. You can achieve this by setting theSender
property: