Hello,
the is a bug in the SmtpClient.
The MailMessage.ReversePath is properly used by the Send method but the SendAsync (the async version of this method) is ingnoring this property.
Regards
Robert
Hi Robert,
Hello,
here is a code sample that demonstrates the correct behavior of the Send method:
MailMessage message = new MailMessage();
message.From = “me@mydomain.com”;
message.To = “doesnotexist@foreigndomain.com”);
message.ReversePath = “bouncesmailbox@mydomain.com”;
SmtpClient client = new SmtpClient(“mysmtpserver”);
client.Send(message);
The expected behavior is that a bounce email should arrive to the bouncesmailbox@mydomain.com address. In case, when the Send() method is used, this works es expected.
here is a sample code where i use SendAsync instead:
MailMessage message = new MailMessage();
message.From = “me@mydomain.com”;
message.To = “doesnotexist@foreigndomain.com”);
message.ReversePath = “bouncesmailbox@mydomain.com”;
SmtpClient client = new SmtpClient(“mysmtpserver”);
client.SendCompleted += OnSendCompleted;
client.SendAsync(message, null);
In this case the bounce email arrives to the address me@mydomain.com which is not the expected outcome.
Regards
Robert
Hi Robert,
Hello,
i am sorry but i can’t provide any access to a SMTP server. But that is not a problem, the sending does not need to be successful to see the difference between Send() and SendAsync().
Simply enable logging for your SmtpClient and you will see in the logfile that in case of Send() the SmtpClient sends a MAIL FROM command that looks like:
MAIL FROM:bouncesmailbox@mydomain.com
which is correct.
If you use SendAsync() you will see:
MAIL FROM:me@mydomain.com
which is incorrect.
Regards
Robert
Hi Robert,
The issues you have found earlier (filed as NETWORKNET-33502) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.