C# 邮件程序 - 550 访问被拒绝 - HELO 名称无效

C# mailer - 550 Access denied - Invalid HELO name(C# 邮件程序 - 550 访问被拒绝 - HELO 名称无效)
本文介绍了C# 邮件程序 - 550 访问被拒绝 - HELO 名称无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道存在与此问题相关的各种线程,但我无法在这些线程上获取任何响应并使其在我的服务器上运行.

所以让我们试着看看是否有人可以帮助我.99% 的电子邮件都能正常发送,而真正返回该错误的电子邮件很少.

我的代码是这样的

 MailMessage mm = new MailMessage(Settings.EmailCustomerService, to, subject, body);mm.SubjectEncoding = 编码.UTF8;mm.BodyEncoding = 编码.UTF8;mm.IsBodyHtml = 真;MailAddress add = new MailAddress(Settings.EmailCustomerService, "客户服务");mm.From = 添加;尝试{SmtpClient 客户端 = 新 SmtpClient(Settings.EmailSMTP);client.UseDefaultCredentials = false;client.Credentials = new NetworkCredential(Settings.EmailUser, Settings.EmailPwd);System.Threading.ParameterizedThreadStart threadStart = new System.Threading.ParameterizedThreadStart(SendInThread);threadStart.Invoke(新的 SendInThreadParams{客户=客户,消息 = 毫米});}最后{毫米=空;}

实际上,凭据代码是后来添加的,但即使没有它,我的代码也可以正常运行.只是碰巧有 1% 的电子邮件从未发送给收件人,而添加这 2 行作为凭据并没有什么不同.

Settings.EmailUser 只是运行 SMTP 的服务器上的一个用户,但我没有将它附加到任何地方.

<块引用><块引用>

我敢打赌这就是问题所在.

SMTP 服务器中继设置为使用 127.0.0.1,而 FQDN 只是机器的名称(类似于Machine1"......没有 domain.com 名称)

我得到的错误是这样的

<块引用>

报告-MTA:dns;Machine1
Received-From-MTA: dns;Machine1
到达日期:2012 年 5 月 30 日,星期三 23:08:36 -0700
最终收件人:rfc822;test@email.net
行动:失败
状态:5.5.0
诊断代码:smtp;550 访问被拒绝 - HELO 名称无效(请参阅 RFC2821 4.1.1.1)

通过电子邮件返回的消息是:

<代码> >这是一个自动生成的传送状态通知.传递到下列收件人失败.test@email.com

在此先感谢...

解决方案

除了message/delivery-status附件,DSN一般都会有返回的message.对于此类问题,您应该发布返回邮件的标题和 DSN.

在我看来,您的服务器已接受该消息,但在继续传输时出错.如果您的服务器拒绝了它,您的代码将引发异常.因此,您的服务器 Machine1 接受了它,并试图将其传输到 email.net,但 email.net 拒绝了它.Machine1 然后生成了一个 DSN(交付状态通知,在您的情况下为 NDR = 未交付报告).

换句话说,这是电子邮件服务器的配置错误,而不是代码问题.几乎可以肯定,问题是电子邮件服务器没有按照您所说的那样设置 FQDN.

作为配置问题,属于ServerFault.

I know there are various thread out there related to this problem but i was unable to take any of the responses on those thread and make it work on my server.

So let try to see if someone can help me out here. 99% of the emails go out properly and few actually return with that error.

My code looks like this

        MailMessage mm = new MailMessage(Settings.EmailCustomerService, to, subject, body);
        mm.SubjectEncoding = Encoding.UTF8;
        mm.BodyEncoding = Encoding.UTF8;
        mm.IsBodyHtml = true;

        MailAddress add = new MailAddress(Settings.EmailCustomerService, "Customer Service");
        mm.From = add;

        try
        {
            SmtpClient client = new SmtpClient(Settings.EmailSMTP);

            client.UseDefaultCredentials = false;
            client.Credentials = new NetworkCredential(Settings.EmailUser, Settings.EmailPwd); 

            System.Threading.ParameterizedThreadStart threadStart = new System.Threading.ParameterizedThreadStart(SendInThread);
            threadStart.Invoke(new SendInThreadParams
            {
                client = client,
                Message = mm
            });
        }
        finally
        {
            mm = null;
        }

Actually the Credentials code was added later but my code was run OK even without it. It just happen that 1% of the email never make it to the recipients and adding those 2 lines for Credentials did not make a difference.

The Settings.EmailUser is just a user on the server where the SMTP runs, but i have NOT attach it to nowhere.

I bet that's the problem.

The SMTP Server Relay is set to use 127.0.0.1 and the FQDN is just the name of the machine (something like "Machine1" ...nothing with a domain.com name)

The error I'm getting is this

Reporting-MTA: dns;Machine1
Received-From-MTA: dns;Machine1
Arrival-Date: Wed, 30 May 2012 23:08:36 -0700
Final-Recipient: rfc822;test@email.net
Action: failed
Status: 5.5.0
Diagnostic-Code: smtp;550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1)

Return message emailed back was:

   > This is an automatically generated Delivery Status Notification.  
   Delivery to the following recipients failed.  
   test@email.com

Thanks in advanced...

解决方案

In addition to the message/delivery-status attachment, the DSN will usually have the returned message. For this sort of issue you should post the headers of the returned message and the DSN as well.

It looks to me like your server has accepted the message, but has an error transmitting it onwards. If your server had rejected it, your code would have thrown an exception. So your server Machine1 accepted it, attempted to transmit it to email.net, but email.net rejected it. Machine1 then generated a DSN (delivery status notification, in your case an NDR = Non-Delivery Report).

In other words it is a configuration error with the email server not a code problem. Almost certainly the issue is that the email server is not set up with an FQDN as you stated.

As a configuration problem, it belongs on ServerFault.

这篇关于C# 邮件程序 - 550 访问被拒绝 - HELO 名称无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)