使用mail.live.com发送邮件在生产服务器上失败

时间:2013-03-08 00:04:52

标签: c# .net email smtpclient

我有一个发送MailMessage电子邮件的简单脚本。这可以工作并发送本地运行的电子邮件。但是,当部署到生产服务器时,我收到此错误

Authentication failed because the remote party has closed the transport stream.

Description: An unhandled exception occurred during the execution of the current web    request. Please review the stack trace for more information about the error and where it  originated in the code. 

Exception Details: System.IO.IOException: Authentication failed because the remote party has closed the transport stream.

Source Error: 

An unhandled exception was generated during the execution of the current web request. >Information regarding the origin and location of the exception can be identified using the exception stack trace below.

邮件代码:

try
{
   SmtpClient smtp = new SmtpClient();
   smtp.EnableSsl = true;
   smtp.DeliveryMethod = SmtpDeliveryMethod.Network; 
   smtp.Send(message);
}

catch (Exception ex)
{
   throw ex;
}

配置设置:

  <system.net>
    <mailSettings>
     <smtp from="support@domain.com">
       <network host="smtp.live.com" password="password" port="587" userName="support@domain.com"  enableSsl="true"/>
     </smtp>
    </mailSettings>
  </system.net>

为什么它在生产中失败的任何想法?

注意使用Gmail时相同的代码(更改端口和主机配置设置后)

1 个答案:

答案 0 :(得分:0)

在网络服务器上添加SSL证书解决了这个问题。