tags:

views:

406

answers:

2

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 do you do this in .Net?

For example say I ([email protected]) want to send an email to you ([email protected]). If [email protected] doesn't exist anymore I want yourserver to send the bounce email to [email protected]). This way when I receive this bounced email I know that [email protected] is not a valid email address anymore and I can update my database accordingly.

In this example, the bounce address would be: [email protected]
How do you specify it using System.Net.Mail?

+2  A: 

Hi, 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 = "[email protected]

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.

Cheers!

Dave

dave wanta
dave - what does your ReversePath property do? As I read the rfc, it should add the path to the 'from' header, and then the receiving server will move it into the return-path header? Is that correct? is that the 'rfc approved' way to handle bounces? I think I will need to delete my answer...
Ray
It is basically the Envelope-From address. It's the value used during the SMTP session when the Mail FROM command is presented to the server.
dave wanta
In this case, isn't it possible to do something like this: message.Headers.Add("Envelope-From", "[email protected]"); Surely what you call 'ReversePath' has to be set in the header in one way or another.
Anthony
I think I see where I went wrong. The software I use to send emails has a property called ReturnPath that is actually the same as Dave's ReversePath property. I got the property name confused with the header name and made an assumption.
Ray
Ok but what I don't understand is which property is set in the header by ReversePath? It should be possible to replicate it by doing something like this: message.Headers.Add("ProperyName", "[email protected]");
Anthony
Anthony -- The ReversePath, ReturnPath, Enevelope-From, and MAIL FROM command value, all refer to the same value. The Return-Path header is set by the *RECIPIENTS* mail server. Not by the sender. The recipients mail server looks at the value of the MAIL FROM command (from the SMTP session) and is supposed to prepend that value in the headers as the Return-Path value. If a Return-Path header already exists, it is to be removed, and replaced.
dave wanta
A: 

The Ultimate Bounce Inspector .NET component will help you. See this blogpost for more details.

Mark Attwood