无法使用SMTP发送电子邮件到外部域 [英] Unable to send emails to external domain using SMTP
本文介绍了无法使用SMTP发送电子邮件到外部域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法使用以下代码将电子邮件发送到外部域名,如user.one@asdf.com。
I am not able to send emails to external domain addresses like 'user.one@asdf.com' using the code below.
SmtpClient smtpClient = new SmtpClient(smtpMailServer);
smtpClient.UseDefaultCredentials = true;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = true;
//Sending mail.
smtpClient.Send(mailMessage);
我收到例外 -
邮箱不可用。服务器响应是:5.7.1无法中继xxx@example.com
如果我将DeliveryMethod更改为 -
If I change the DeliveryMethod to -
smtpClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
我可以在本地机器上发送电子邮件。但是在生产站点出现异常 -
I am able to send the emails on my local machine. But it fails on the production site with an exception -
无法获取IIS代理目录
你能否建议我该怎么办?
Can you please suggest me what to do?
推荐答案
我有这个问题和认证固定如下所示:
I had this issue and authenticating fixed it see below:
SmtpClient client = new SmtpClient(EmailServer, 25);
var SmtpUser = new System.Net.NetworkCredential("domain\\username", "password");
client.Credentials = SmtpUser;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
我不得不使用双斜杠,因为一个斜杠是转义字符,所以使用两个它来工作。
I had to use the double slash since one slash is the escape character so use two for it to work.
这篇关于无法使用SMTP发送电子邮件到外部域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文