无法从Azure云服务连接到SMTP [英] Not able to connect to smtp from Azure Cloud Service

查看:106
本文介绍了无法从Azure云服务连接到SMTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Azure上托管了2个云服务.

这两种服务都依赖于我们的smtp服务器发送邮件.

问题是Azure云服务无法连接到我们的smtp服务器.

我们能够在内部计算机上使用相同的代码,而不会出现任何问题.我们还检查了25个端口是否已打开,并且IP地址也未列入黑名单.

以下是从云服务进行连接时的错误:

连接尝试失败,因为被连接方未一段时间后正确响应或建立连接失败,因为连接的主机未能响应111.93.111.42:25

电子邮件发送逻辑

  MailMessage消息=新的MailMessage(senderID,提醒.用户名,template.Subject,正文);message.From =新MailAddress(data.SenderEmail,data.SenderName);message.IsBodyHtml = true;尝试{SmtpClient smtp =新的SmtpClient{主机= data.SMTPServer,//此处的smtp服务器地址...端口=数据.端口号,EnableSsl = data.SSL,DeliveryMethod = SmtpDeliveryMethod.Network,凭据=新的System.Net.NetworkCredential(senderID,senderPassword),超时= 30000,};smtp.Send(消息);//线程=新线程(()=> {smtp.Send(message);});//th.Start();}抓住(前例外){ErrorLogging.ErrorLog(例如,错误提醒发送邮件-员工提醒邮件错误消息:" + ex.Message,员工提醒邮件","0","EmployeeRemindersMail",schemaName,companyId);} 

解决方案

Microsoft建议Azure客户使用经过身份验证的SMTP中继服务(通常通过TCP端口587或443连接,但通常也支持其他端口)来发送电子邮件.Azure VM或来自Azure App Services.这些服务专门研究发件人的信誉,以最大程度地降低第三方电子邮件提供商拒绝邮件的可能性.此类SMTP中继服务包括但不限于 SendGrid .也可以在可以使用的前提下运行安全的SMTP中继服务.无论订阅类型如何,在Azure中都不会限制使用这些电子邮件传递服务.

参考: https://blogs.msdn.microsoft.com/mast/2017/11/15/enhanced-azure-security-for-sending-emails-november-2017-update/

您可能还希望引用

Microsoft recommends that Azure customers employ authenticated SMTP relay services (typically connected via TCP port 587 or 443, but often support other ports too) to send e-mail from Azure VMs or from Azure App Services. These services specialize in sender reputation to minimize the possibility 3rd party e-mail providers will reject the message. Such SMTP relay services include but are not limited to SendGrid. It is also possible you have a secure SMTP relay service running on premises that can be used. Use of these e-mail delivery services is in no way restricted in Azure regardless of subscription type.

Reference: https://blogs.msdn.microsoft.com/mast/2017/11/15/enhanced-azure-security-for-sending-emails-november-2017-update/

You may also want to refer this thread which addresses similar issue and see if that helps.

这篇关于无法从Azure云服务连接到SMTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆