Operating System - HP-UX
1820271 Members
3446 Online
109622 Solutions
New Discussion юеВ

Error sending e-mails from Java - ehlo problem

 
P-Dicky
Frequent Advisor

Error sending e-mails from Java - ehlo problem


Hello Everyone

So trying to send e-mail with Javamail 1.4ea I get the following on my prod server (this is in debug mode). I'm using HPUX 11.11


On Prod

DEBUG: setDebug: JavaMail version 1.4ea
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "172.30.1.20", port 25, isSSL false
220 fandpmfg.com [ESMTP Server] service ready;ESMTP Server; 02/08/08 14:03:26

DEBUG SMTP: connected to host "172.30.1.20", port: 25

EHLO

501 Syntax error in parameters or arguments -

HELO

501 Syntax error in parameters or arguments -

javax.mail.MessagingException: 501 Syntax error in parameters or arguments -


On Demo my demo server

DEBUG: setDebug: JavaMail version 1.4ea
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "172.30.1.20", port 25, isSSL false
220 fandpmfg.com [ESMTP Server] service ready;ESMTP Server; 02/08/08 14:05:16

DEBUG SMTP: connected to host "172.30.1.20", port: 25

EHLO demoglo

250-fandpmfg.com

250-SIZE 26214400

250-8BITMIME

250 STARTTLS

DEBUG SMTP: Found extension "SIZE", arg "26214400"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: use8bit false

The prod server is always doing my dns resolving... Any tips?

Thank you
Paul
8 REPLIES 8
VK2COT
Honored Contributor

Re: Error sending e-mails from Java - ehlo problem

Hello,

Simple Mail Transfer Protocol RFCs stipulate use of HELO and EHLO.

Invalid usage of HELO/EHLO in the SMTP dialogue is your problem.

I used to own and run a Linix-based ISP,
so I dealt with these kind of issues
regularly :)

FQDN in the SMTP EHLO statement is enough to block close to 25% of incoming spam.

Most Mail Transfer Agents (MTAs)perform DNS
(A- and PTR- resource records) verification
on the domain name given on the SMTP HELO
and EHLO commands. This can violate RFC 2821,
so email is usually not rejected by default.

In other words, EHLO and HELO typically
require FQDN. Some examples for a properly
set MTA (same applies to HELO and EHLO):

Invalid HELO localhost
Invalid HELO 127.0.0.1
Valid HELO mydomain.dom
Valid HELO [127.0.0.1]

If you get an error message saying "Improper
HELO/EHLO", it is due to the connecting
computer or session not complying with the
SMTP standard. More specifically, it had an
invalid argument to the HELO-command. There
are several ways of getting this wrong.

RFC 2821, section 4.1.1.1 states:

A client MUST issue HELO or EHLO before
starting a mail transaction.

A mail transaction is started by the command
MAIL FROM.

I remember some Java applications at private hospital group that could not set the
EHLO/HELO properly. In the end, to help them, I devised a solution that used Procmail
filtering. Procmail was receiving email
from Java applications, then adding all appropriate headers and ensuring
SMTP standards, and finally forwarding
to external sites. I did it in 2002
and recently that company approached me
and said they still used the solution :)

I hope this helps,

VK2COT
VK2COT - Dusan Baljevic
Heironimus
Honored Contributor

Re: Error sending e-mails from Java - ehlo problem

Read the previous detailed answer because you'll save yourself a lot of headaches if you strictly follow the standards, but the short answer is that your prod system appears to be sending just "EHLO" instead of the correct "EHLO client-name". It's probably an application configuration problem, you may have missed something when you moved to prod.
P-Dicky
Frequent Advisor

Re: Error sending e-mails from Java - ehlo problem

I understand the problems and why it exists. I'm just wondering where to correct it on the HPUX side. The e-mail is just a report going to my local mail server.
VK2COT
Honored Contributor

Re: Error sending e-mails from Java - ehlo problem

Hello,

The problem is not on the HP-UX side. The
problem is your improperly set up Java
application.

Like everything in life, certain rules of
the engagement should be respected.

However, this is your private server and you
can by-pass all RFCs if you wish so :)
On internet, I can assure you that your
messages would be rejected on the spot.

Therefore, look at confPRIVACY_FLAGS in
sendmail.cf:

needmailhelo
needvrfyhelo
needexpnhelo

These three flags cause Sendmail to require a valid HELO/EHLO command from the client before accepting certain other commands.

Cheers,

VK2COT
VK2COT - Dusan Baljevic
P-Dicky
Frequent Advisor

Re: Error sending e-mails from Java - ehlo problem

Great tip but the problem is sending e-mail from that server not receiving... These all look like settings if you are accepting e-mail. Am I wrong?
VK2COT
Honored Contributor

Re: Error sending e-mails from Java - ehlo problem

Hello,

When your JavaMail on the production server
is sending an email message, it tries to
connect to SMTP server at IP address
172.30.1.20 on port 25. It is duty of
JavaMail to introduce itself to the
SMTP gateway. In other words, in should
send "EHLO FQDN" firstly. The demo server
is doing it but the production one is not.

Cheers,

VK2COT
VK2COT - Dusan Baljevic
P-Dicky
Frequent Advisor

Re: Error sending e-mails from Java - ehlo problem

See I know the demo server is doing it! Just wondering where that setting is on the production server...
VK2COT
Honored Contributor

Re: Error sending e-mails from Java - ehlo problem

Hello,

Maybe check vendor's documentation and:

http://java.sun.com/products/javamail/FAQ.html

The FAQ says:

The SMTP provider uses the results of
InetAddress.getLocalHost().getHostName() in
the SMTP HELO command. If that call fails to
return any data, no name is sent in the
HELO/EHLO command. Check your JDK and name
server configuration to ensure that that
call returns the correct data. You may also
set the "mail.smtp.localhost" property to the
name you want to use for the HELO/EHLO
command.

In other words, something like:

Properties props = new Properties();
props.put("mail.smtp.host", args[0]);
props.put("mail.smtp.localhost", "mysrv.mydomain.dom");
mailSession = javax.mail.Session.getDefaultInstance(props, null);
...

Cheers,

VK2COT
VK2COT - Dusan Baljevic