How to set the bounce address using System.Net.Mail?
I'm trying to implement the Variable envelope return path (VERP) method to manage email addresses (ie when an email I send bounces back I want it to be sent to a specific email address so that I can update my database to avoid sending emails to that email address in the future).
According to this article it is possible to specify the email address a bounce email is sent to. How开发者_如何学JAVA do you do this in .Net?
For example say I (me@myserver.com) want to send an email to you (you@yourserver.com). If you@yourserver.com doesn't exist anymore I want yourserver to send the bounce email to bounce-you=yourserver.com@myserver.com). This way when I receive this bounced email I know that you@yourserver.com is not a valid email address anymore and I can update my database accordingly.
In this example, the bounce address would be: bounce-you=yourserver.com@myserver.com
How do you specify it using System.Net.Mail?The bottom line is that you cannot do this in .NET. You can only set the FROM address, which System.Net.Mail will also use as the Envelope-From.
To do something like this, you would need to use a 3rd party SMTP object like the one I wrote:
http://www.aspnetemail.com
In aspNetEmail, you can do something like:
EmailMessage msg = new EmailMessage();
msg.ReversePath = "bounceEmailAccountHere@whatever.com
aspNetEmail will use the ReversePath value in the MAIL FROM command during the SMTP Session. I could have easily of called this property "ReturnPath" or "EnvelopeFrom". In retrospect, EnvelopeFrom would have been a better name.
精彩评论