• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

JavaMail Exception "HELO requires domain address"

 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you've seen this before, then all you'll need is the subject line, but here's some more details:
I don't think there's anything wrong with that code (aside from it's propensity to throw null pointers and/or arrayindexoutofbounds exceptions.

Running it produces:
the 501 response is from my mail provider, so I know it's not connectivity. Anything I can find on this response (God bless Google) indicates a problem with the DNS setup of the system I am trying to send email *from*.

So if I go to my Operations guy I want to be able to tell him I'm confident my code is not the problem, but currently I'm not sure where to point him. He doesn't know anything about how JavaMail works, and I don't know anything about configuring a Solaris box to play nice with the smtp provider.

Has anyone encountered this problem, and it's solution?
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Mike,
Have you tried "mail.host" rather then "mail.smtp.host"? I tried your setting and it appears to look for a local smtp server rather then a remote one.
Properties p = new Properties();
p.put("mail.host", (String)config.get("mailServer"));
Session con = Session.getInstance(p, null);
Works for me.
Good Luck,
Craig
oops, didn't need html there..
------------------
SCJP2
[This message has been edited by Craig O'Brien (edited December 20, 2001).]
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That didn't help in my case.

I think it's a more fundamental problem than that. I connect to the provider, because the error message is from my smtp server.

the problem is.. from where does JavaMail get the name of the box that it is trying to send from?

If I use sendmail on this box, I can send to the same mail server with no problem, because in sendmail you can tell it to 'fake out' the DNS. You can tell sendmail to reply with 'esweb1.mydomain.com' when the smtp asks for it.

Where in JavaMail (what's the property?) do I tell it to reply with this value? Or is it even possible to tell JavaMail to fake out the domain of the sending box? (Does it get it from the DNS configuration of the box).

My Operations guy is in the process of getting this box name placed into DNS, which might take a few days, but in the meantime, I'm wondering if I can fake it, like you can with sendmail.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Downloading the source code for j2ee, I found inside the source of STMPTransport class, the following:So there's my answer for how JavaMail gets it.. it's from the InetAddress class. And Yes, it's possible to fake out the response by including a 'mail.smtp.localhost' property as in the following modified code from my first post...
[This message has been edited by Mike Curwen (edited December 20, 2001).]
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just a dumb question: Is javax.mail package part of only j2ee? I could not locate mail
package in standard edition!
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Suheel -
It's an unbundled extension you download separately. Here's the splash page if you wish.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or, if you download the j2sdkee j2ee.jar contains the Mail api classes.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just a bit of extra info on this problem:
If you look at the code in the SMTPTransport class, it will cache the name of the localhost, so you'll need to make sure that your servlet container gets restarted if you change the value of the mail.smtp.localhost property to ensure that the SMTPTransport class gets reloaded (may or may not happen when your class is reloaded). This burned about an hour and a half of my time today...
dan
 
Ranch Hand
Posts: 551
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I have the same problem , How do you resolve it ?
I am using a remote machine as a mail server to send my emails ,
what should value of mail.smtp.localhost be ?
should i use the remote machine name / domain name in it or it should be my local machine the email sending java code is executing ?

Thanks
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I also had this one on CentOS5 and tomcat6.

I used Mike Curwen's solution, in my instance: props.put("mail.smtp.localhost", "127.0.0.1");
It's obviously not the root of the problem but an acceptable workaround.

And for anyone still affected:
http://java.sun.com/products/javamail/FAQ.html#helo
http://weblogs.java.net/blog/2004/10/11/blarg8-stupid-user-trick-goggle-cache
http://jira.atlassian.com/browse/JRA-9892
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! Im having the same problem, but changing the mail.smtp.localhost to 127.0.0.1 didnt work. I can send mails with the same code in a separate class, but when i try it in a class mounted on a Jboss i get the "Send helo first" error, any ideas. Thanks
 
Emilio de la Torre
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Always jumps "send hello first" error

props.put("mail.smtp.transport.protocol", "smtp");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtpserver.domain.com");
props.put("mail.smtp.localhost", "mypc.mydomain.com);
props.put("mail.smtp.auth", "true");

Session sesion = Session.getDefaultInstance(props);

try {
Transport transport = sesion.getTransport("smtp");
MimeMessage msg = new MimeMessage(sesion);
sesion.setDebug(true);

msg.setFrom(new InternetAddress("[email protected]"));

InternetAddress[] address = { new InternetAddress("[email protected]") };

msg.addRecipients(Message.RecipientType.TO, address);
msg.setSubject("Test");
msg.setText("This is a test", "text/plain");


transport.connect(host, port, username, password);
transport.sendMessage(msg, msg.getRecipients(Message.RecipientType.TO));
transport.close();
} catch (MessagingException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
 
That which doesn't kill us makes us stronger. I think a piece of pie wouldn't kill me. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic