Currently sending emails and setting the Return-path of an email(System.Net.Mail) works if i put :
MailMessage msg = new MailMessage();
msg.Sender = new MailAddress("not-deliviered@sample.org");
msg.Headers.Add("Return-Path", sReturnPath);
but if I send a successful email it would say delivered on behalf of the email above….
any ideas how to resolve this not to put ‘on behalf of’ but if it bounces back should return to ‘not-delivered’?
thanks
The sender property is where you are getting that value from.
Although you can set the Return-Path header, according to the RFCs, the accepting mail server is supposed to remove any Return-Path header values, and place a Return-Path header value with the value of the envelope MAIL FROM command.
What you want to do, is use the not-delivered@sample.org as the MAIL FROM command value and a human read-able value in the normal FROM header. You cannot do this in System.Net.Mail. Whatever you use as the FROM value will be used as the MAIL FROM value.
You have to use a 3rd party product.
–Dave
PS:
— Shameless plug–
Like aspNetEmail, which is my product, and supports this functionality.