开发者

Sending Email over VPN SmtpException net_io_connectionclosed

开发者 https://www.devze.com 2022-12-26 19:33 出处:网络
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

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.Re开发者_StackOverflow社区adLines(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?


I solved this by connecting outlook on a VPN machine to the Exchange server. The IP address automatically resolved to a different server name than the one I was trying. Evidently the exchange server was only available over VPN through the other URL.

0

精彩评论

暂无评论...
验证码 换一张
取 消