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?
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).]
Sun Certified Programmer for the Java 2 Platform<br />Senior Software Engineer<br />TechRx
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.
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).]
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
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 ?
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