故障排除"邮箱不可用.服务器响应是:访问被拒绝-无效的HELO名称.使用SmtpClient发送电子邮件时 [英] Troubleshooting "Mailbox unavailable. The server response was: Access denied - Invalid HELO name" when sending email with SmtpClient

查看:76
本文介绍了故障排除"邮箱不可用.服务器响应是:访问被拒绝-无效的HELO名称.使用SmtpClient发送电子邮件时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试通过C#发送电子邮件.我在Google上搜索了各种示例,并从每个人和每个人都可能会使用的标准代码中获取了点滴.

I have been trying to send an email by C#. I have Googled for various examples and have taken bits and pieces from each and from the standard code which everyone would most probably be using.

string to = "receiver@domain.com";
string from = "sender@domain.com";
string subject = "Hello World!";
string body =  "Hello Body!";
MailMessage message = new MailMessage(from, to, subject, body);
SmtpClient client = new SmtpClient("smtp.domain.com");
client.Credentials = new NetworkCredential("test@domain.com", "password");
client.Send(message);

但是,我不断收到错误提示

However, I keep getting an error stating

System.Net.Mail.SmtpException:邮箱不可用.服务器响应为:拒绝访问-无效的HELO名称(请参阅RFC2821 4.1.1.1)

System.Net.Mail.SmtpException: Mailbox unavailable. The server response was: Access denied - Invalid HELO name (See RFC2821 4.1.1.1)

那么,我现在该怎么办?SmtpClient是否应该是特殊的,并且只能在特定的SMTP服务器上使用?

So, what do I do now? Is SmtpClient supposed to be special and only work on specific SMTP servers?

推荐答案

看来您的用户名/密码对未通过SMTP服务器成功认证.

我认为,我发现这里有问题.我已经在下面更正了您的版本.

I think, I found what's wrong here. I have corrected your version below.

string to = "receiver@domain.com";

//It seems, your mail server demands to use the same email-id in SENDER as with which you're authenticating. 
//string from = "sender@domain.com";
string from = "test@domain.com";

string subject = "Hello World!";
string body =  "Hello Body!";
MailMessage message = new MailMessage(from, to, subject, body);
SmtpClient client = new SmtpClient("smtp.domain.com");
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("test@domain.com", "password");
client.Send(message);

这篇关于故障排除"邮箱不可用.服务器响应是:访问被拒绝-无效的HELO名称.使用SmtpClient发送电子邮件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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