I am sending an email from a WPF application. When sending as a domain user on the network, the emails sends as expected. However, when I attempt to send email over a VPN connection, I get the following exception:
Exception: System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed. at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine) at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine) at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller) at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message)
I have tried using impersonation as well as setting the Credentials on the SmtpClient. Neither seem to work:
using (new ImpersonateUser("myUser", "MYDOMAIN", "myPass"))
{
var client = new SmtpClient("myhost.com");
client.UseDefaultCredentials = true;
client.Credentials = new NetworkCredential("myUser", "myPass", "MYDOMAIN");
client.Send(mailMessage);
}
I've also tried using Wireshark to view the message over the wire, but I don't know enough about SMTP to know what I'm looking for.
One other variable is that the machine I'm using on the VPN is Vista Business and the machine on the network is Win7. I don't think it's related, but then I wouldn't be asking if I knew the issue! :)
Any ideas?