501 5.5.4 Invalid HELO/EHLO argument / syntax error in parameters

The server did not like the arguments your client sent with a command, most often the hostname in HELO or EHLO. Servers expect a fully qualified hostname or an address literal in brackets; a bare word, a name with spaces, an underscore, or an empty argument gets this reply, and some servers refuse the session afterwards.

What the server replies

501 5.5.4 Invalid domain name

Sent by
Any mail server
Type
PermanentRetry fails
About
Connection
Enhanced code
5.5.4

Who sends it

Exchange ("501 5.5.4 Invalid domain name" and "Invalid Address" for a malformed MAIL FROM), Postfix ("501 5.5.4 Syntax: HELO hostname" and "504 5.5.2 Helo command rejected: need fully-qualified hostname" when strict), and any server following RFC 5321.

Why it happens

  • The MTA's hostname is set to a single label like "mailserver" or "localhost".
  • An application library sends the machine's local name, which is not a valid domain.
  • The hostname contains an underscore or starts with a digit and the server validates strictly.
  • A MAIL FROM or RCPT TO address with unbalanced angle brackets or a space.

How to fix it

  1. Set a fully qualified HELO name

    Configure myhostname (Postfix), primary_hostname (Exim) or the equivalent to a real hostname such as mail.example.com that resolves to the server's IP.

  2. Set the client's local hostname

    Libraries like Nodemailer, PHPMailer and smtplib let you pass the name to use in EHLO. Set it to your domain rather than relying on the machine name.

  3. Check address syntax

    Make sure addresses are wrapped as <user@domain> with no spaces and that display names are not leaking into the envelope.

Check it yourself

These free tools show the records and connections behind this code for your own domain or server.

Related codes

Sources

Fewer bounces to look up.

Faivelo sends from authenticated, warmed infrastructure, turns permanent bounces into one clean event for your application and keeps the address out of future sends.

Send with Faivelo

Free tier included. No card needed.