【问题标题】:SMTP not working on Azure websites on 64 bit modeSMTP 在 64 位模式下无法在 Azure 网站上运行
【发布时间】:2013-06-04 18:00:25
【问题描述】:

几个月前我在 Azure 网站上部署了一个应用程序,它按预期工作。昨天,在微软发布了一组新功能后,我注意到有一个选项可以从 32 位更改为 64 位。我将网站配置从 32 位更改为 64 位。除了我尝试使用标准 SMTP .NET 库通过 SendGrid 发送电子邮件时,所有网站都可以正常工作。

这是我得到的例外:

访问被拒绝" source="System" detail="System.Net.NetworkInformation.NetworkInformationException (0x80004005):访问在 System.Net.NetworkInformation.SystemIPGlobalProperties.GetFixedInfo() 在系统被拒绝.Net.NetworkInformation.SystemIPGlobalProperties.get_FixedInfo() 在 System.Net.NetworkInformation.SystemIPGlobalProperties.get_HostName() 在 System.Net.Mail.SmtpClient.Initialize() 在 System.Net.Mail.SmtpClient..ctor()

这是代码:

var toAddress = new MailAddress(to, username);
using (var smtp = new SmtpClient())
using (var message = new MailMessage() {Subject = subject, IsBodyHtml = true})
{
    message.To.Add(toAddress);
    message.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(body, null, MediaTypeNames.Text.Html));
    smtp.Send(message);
}

Web.config:

<system.net>
  <mailSettings>
    <smtp from="xxx@xxx.com">
      <network host="smtp.sendgrid.net" port="587" userName="xxx@azure.com" password="xxxxx" />
    </smtp>
  </mailSettings>
</system.net>

我的开发环境配置为 64 位,应用程序可以发送电子邮件。 知道为什么它在 Azure 64 位模式下会失败吗?

谢谢!

【问题讨论】:

  • 您是在Full Trust 还是Windows Azure Partial Trust 中部署您的云服务?
  • 我正在使用网站进行部署。默认情况下是完全信任的。
  • 我遇到了同样的问题。将其切换回 32 位修复它。有人对差异有解释吗?
  • 我遇到了同样的问题,将它改回 32 位修复了它。最奇怪的事情。很想知道为什么。

标签: azure smtp 64-bit


【解决方案1】:

我遇到了这个问题,并发现我在 web.config 文件和 Azure 应用设置中有冲突的值。我不确定这些在 Azure 中是如何工作的,因为它们似乎没有直接映射到 web.config 应用程序设置。删除所有 Azure 应用程序设置(并保留 web.config)后,通过 gmail 发送电子邮件没有问题。

【讨论】:

  • 感谢您的评论。我会检查我的设置以确认是否有什么不合适的地方。
  • 我结束了网络角色的转变,它在 64 位上运行良好。我停止研究该网站的可能解决方案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-04
  • 1970-01-01
  • 2012-07-13
  • 2015-11-22
  • 2014-05-16
  • 1970-01-01
相关资源
最近更新 更多