我有一个简单的脚本来发送 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 时相同的代码有效(更改端口和主机配置设置后)