【发布时间】:2011-02-08 13:18:35
【问题描述】:
我正在从 WPF 应用程序发送电子邮件。在网络上作为域用户发送时,电子邮件按预期发送。但是,当我尝试通过 VPN 连接发送电子邮件时,出现以下异常:
例外:
System.Net.Mail.SmtpException:发送邮件失败。 ---> System.IO.IOException:无法从传输连接读取数据:net_io_connectionclosed。 在 System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(字节 [] 缓冲区,Int32 偏移量,Int32 读取,布尔读取行) 在 System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader 调用者,布尔 oneLine) 在 System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader 调用者) 在 System.Net.Mail.SmtpConnection.GetConnection(字符串主机,Int32 端口) 在 System.Net.Mail.SmtpTransport.GetConnection(字符串主机,Int32 端口) 在 System.Net.Mail.SmtpClient.GetConnection() 在 System.Net.Mail.SmtpClient.Send(MailMessage 消息)
我尝试过使用模拟以及在 SmtpClient 上设置凭据。似乎都不起作用:
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);
}
我也尝试过使用 Wireshark 通过网络查看邮件,但我对 SMTP 的了解不够,无法知道我在寻找什么。
另一个变量是我在 VPN 上使用的机器是 Vista Business,而网络上的机器是 Win7。我不认为这是相关的,但我不会问我是否知道这个问题! :)
有什么想法吗?
【问题讨论】:
标签: c# .net smtp smtpclient