发送电​​子邮件使用Windows虚拟邮件服务器的头球回传路径

问题描述:

我试图使用.NET类MAILMESSAGE也可以添加返回路径头发送电子邮件,以使任何反弹回来到不同的电子邮件地址。代码如下:

I'm trying to send an email message using the .NET MailMessage class which can also have the return-path header added so that any bounces come back to a different email address. Code is below:

            MailMessage mm = new MailMessage(new MailAddress(string.Format("{0}<{1}>", email.FromName, email.FromEmail)), new MailAddress(emailTo));
            mm.Subject = ReplaceValues(email.Subject, nameValues);
            mm.ReplyTo = new MailAddress(string.Format("{0}<{1}>", email.FromName, email.FromEmail));
            mm.Headers.Add("Return-Path", ReturnEmail);

            // Set the email html and plain text
            // Removed because it is unneccsary for this example

            // Now setup the smtp server
            SmtpClient smtp = new SmtpClient();
            smtp.Host = SmtpServer;
            smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;

            if (SmtpUsername.Length > 0)
            {
                System.Net.NetworkCredential theCredential = new System.Net.NetworkCredential(SmtpUsername, SmtpPassword);
                smtp.Credentials = theCredential;
            }

            smtp.Send(mm);



每当我检查被送到我检查了头,它似乎总是缺少报税表中的电子邮件路径。有什么我缺少正确配置呢?正如我上面说的我用我的开发机(XP)的标准虚拟邮件服务器但它会在Windows 2003最终运行。

Whenever I check the email that was sent I check the header and it always seems to be missing return-path. Is there something I am missing to configure this correctly? As I said above I'm using the standard Virtual Mail Server on my development machine (XP) however it will run on Windows 2003 eventually.

有没有人有任何想法,为什么它不是未来通过?

Has anyone got any ideas why it isn't coming through?

返回路径基础上,SMTP MAIL FROM信封设置。您可以使用发件人属性做这样的事情

另一个讨论相关问题,您将有迟早:的 http://stackoverflow.com/questions/51793/how-can-you-set-the-smtp

The Return-Path is set based on the SMTP MAIL FROM Envelope. You can use the Sender property to do such a thing.
Another discussion on a related issue you will have sooner or later: http://stackoverflow.com/questions/51793/how-can-you-set-the-smtp-envelope-mail-from-using-system-net-mail

和BTW使用系统净邮件-envelope邮件 - 从-,如果使用SmtpDeliveryMethod.PickupDirectoryFromIis,发件人属性不作为一个MAIL FROM;你必须使用网络作为一种交付方式,以保持该值。
我没有找到这个问题的任何解决办法。

http://stackoverflow.com/questions/457880/pickupdirectoryfromiis-sender-property-and-smtp-mail-from-envelope

And btw, if you use SmtpDeliveryMethod.PickupDirectoryFromIis, the Sender property is not used as a MAIL FROM; you have to use Network as a delivery method to keep this value. I did not find any workaround for this issue.
http://stackoverflow.com/questions/457880/pickupdirectoryfromiis-sender-property-and-smtp-mail-from-envelope