1

I am trying to connect to Mercury mail server with a java application and I am using JavaMail api. The connection is not successful and I’m getting this error in the log:

EHLO x.x.x.x
554 Invalid HELO format

Which means that it connects to the server but the helo format is not something that sever likes. I've tired to debug it and I got to this code in JavaMail “SMTPTransport” class which says:

serverOutput.write(cmdBytes);
serverOutput.write(CRLF);
serverOutput.flush();

and according to code: private static final byte[] CRLF = { (byte)'\r', (byte)'\n' };
which seems consistent with RFC 821

I know that on windows \n has different meaning but I am not sure if this really is the root of problem? If it not then what can cause this? I checked mail server with mail client and it works fine and I checked the code with James mails server and it also works fine!

JavaMail API version is: 1.4.5 (latest release)
Mercury/32 : 4.7

chs
  • 652
  • 4
  • 17
Fred Jand
  • 699
  • 7
  • 25
  • How is the Mercury server configured with regards to validating the client hostname? The parameter to EHLO is supposed to be the fqdn of the client (but can be the client's IP if no fqdn is available). The Mercury server might be set to verify reverse DNS on the client and/or reject non-routable client addresses. The best bet is to capture a session from a working client using Wireshark and compare to a failing session. – Jim Garrison Oct 16 '12 at 03:24
  • Also, what is the encoding definition of `serverOutput`? If it's not binary, then you may actually be sending CR-CR-LF, which might be a problem. – Jim Garrison Oct 16 '12 at 03:25
  • About serverOutput I am not sure how it exactly works I can’t get into the source code as I mentioned it is part of JavaMail API package, but I agree with you and mentioned in my post that I suspicious this CRLF might be CR CR LF as you said – Fred Jand Oct 16 '12 at 04:33
  • I have tried telnet to the server and send Ehlo with the same IP address works fine. Note that this all happening on a the same machine, the server the sender and the receiver are all localhost. I am not sure which settings might have effect on this, where can I check that? – Fred Jand Oct 16 '12 at 04:37

3 Answers3

2

I did a Google search on 554 Invalid HELO format and got a ton of hits about your specific Mercury problem. It's a bug.

http://community.pmail.com/forums/thread/4136.aspx

http://www.mantisbt.org/bugs/view.php?id=9645

http://ellislab.com/codeigniter/forums/viewthread/153130/

etc...

Kumar V
  • 8,810
  • 9
  • 39
  • 58
Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
  • That is it! Thanks. I don't get it, the post is more than 4 years old and the one in the main mercury forum is 5 years old and they haven't fix it yet?! – Fred Jand Oct 16 '12 at 12:19
1

You might need to check the logs on the server to figure out what it's really complaining about, but... One thing you can try is setting the mail.stmp.localhost property to the correct DNS host name for your machine. From the debug output it looks like your machine is unable to determine its own name and so is sending the IP address instead.

Bill Shannon
  • 29,579
  • 6
  • 38
  • 40
  • this was the log from server, the server an application are both on localhost, I think the ip is the clients ip not the server here! EHLO is comes form client and it post its IP with it, I use 127.0.0.1 but the same happes – Fred Jand Oct 16 '12 at 02:04
  • Your application is the client as far as the mail server is concerned. The EHLO command is supposed to include the host name of the client machine, in your case either "localhost" or the real DNS name on the client/server machine. "127.0.0.1" is not a host name, it's an IP address. Set the property to an actual host name. – Bill Shannon Oct 16 '12 at 06:21
0

For me in a web project the PHPMailer() class was forcing Auth. Changing the Auth to false fixed it. Maybe check similar option for setting Auth to false in your language.

This is what I changed in my PHP code from true to false and adding sendmail_from in the php.ini file

    $mail = new PHPMailer();
    $mail->SMTPAuth = false;
Syed Waqas Bukhary
  • 5,130
  • 5
  • 47
  • 59