The SMTP RFC specifies exactly what syntax is allowed for the HELO command, and when keying it manually, it is easy to make a syntax error.
The reason to connect to localhost on port 25 to attempt these tests, is that a firewall may be changing your SMTP commands in transit, or causing that error message. The only reliable way to rule out the possibility of an unanticipated intermediary is to connect to localhost and see the same behavior.
There are various types of Layer 2 hidden/trasparent bridges and even traditional L3 firewalls that _WILL_ modify SMTP traffic in transit, according to various types of access rules, spam filter definitions, etc.
PIX/ASA mail-guard come to mind.
For example, with a PIX/ASA in between you and the server you are telnetting to.
If you type just "Helo"
instead of "HELO mydomain.com"
The firewall will cause you to receive the very error message you state.
Try
telnet IP-Address port 25
type:
HELO mydomain.com
*Make sure HELO is typed in all caps.
*In place of mydomain.com, make sure that the hostname you type is valid and reverse-resolves to the host you are sending mail from.
Make sure that you are using a proper telnet client, such as the one included in CentOS by default.
POSTFIX should not say "error: command not recognised"
in response to HELO
Although "502 5.5.2 Error: command not recognized" is indeed the postfix response to an unknown command