C# mailer – 550 Access denied – Invalid HELO name

csmtp

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…

Best Answer

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.