我正在努力让我的 SMPT 电子邮件在 Azure 网站中正常工作。 这适用于我的本地设置:
<mailSettings>
<smtp deliveryMethod="Network">
<network host="relay.myIsp.net" userName="" password="" port="25" />
</smtp>
</mailSettings>
我已将 ISP 的名称更改为“myIsp”,除此之外它是相同的。
我读过一些有关 Azure.config 冲突的帖子,但我找不到它。
我正在使用 ActionMailer.Net,它看起来很棒,作为我的电子邮件消息生成器。
应用程序确实执行完毕,没有错误。我只是没有收到电子邮件。
提前致谢。
编辑:
SendGrid Web.config 设置,因此 Azure 网站上的端口 25 或 587 没有问题:
<system.net>
<mailSettings>
<smtp from="<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c2b6a7b1b682a6adafa3abaceca1adaf" rel="noreferrer noopener nofollow">[email protected]</a>">
<network host="server" password="password" userName="username" port="587" />
</smtp>
</mailSettings>
</system.net>
最佳答案
据我所知,Azure 网站和 Web 角色不会阻止端口 25 或端口 587,因为我尝试使用这些端口使用 SendGrid 和其他电子邮件帐户而不会出现问题。
但是,查看您的配置,我怀疑缺少用户名和密码可能是原因。使用开放中继来发送电子邮件是一个很大的安全漏洞(想想垃圾邮件网关)。通常,您必须向电子邮件服务器进行身份验证才能发送电子邮件。至于在家工作,这可能只是因为您通过它们连接到电子邮件服务器(您位于 ISP 的调制解调器和 IP 子网上)并且它们自动知道这是一个正常的连接。
为了进行故障排除,我建议尝试使用 SendGrid 或 Gmail 帐户。如果有效,那么它会指出您的 ISP 存在配置问题。
Gmail 配置示例:
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network defaultCredentials="false" enableSsl="true" host="smtp.gmail.com" port="587" userName="<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2b535353535353536b4c464a424705484446" rel="noreferrer noopener nofollow">[email protected]</a>" password="xxxxxxxxxxx"/>
</smtp>
</mailSettings>
</system.net>
关于asp.net-mvc - 尝试在 Azure 网站的 Web.config 中正确配置 SMTP。无法上类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23198923/