Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

MessagingException: 501 Syntax: HELO hostname. Very Urgent

843830Dec 1 2006 — edited Aug 20 2008
Hi,
I am getting an error message : "MessagingException: 501 Syntax: HELO hostname" when trying to send mail using Java Mail API. Can anyone plz help me. It's very urgent. I am using this code. I had using the host name as my mail server name.


try
{
String host = "smtp.xxxxx.com";
String from = "abc@xyz.com";
String to="me@xyz.com";
String htmlText=null;
to = fremail;


Properties props = System.getProperties();
props.put("mail.smtp.host", host);
props.put("mail.smtp.starttls.enable", "true");
Session session1 = Session.getDefaultInstance(props, null);

MimeMessage message = new MimeMessage(session1);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject("Hai. Mail send using Java Mail");
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setContent(htmlText, "text/html");
MimeMultipart multipart = new MimeMultipart("related");
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
Transport.send(message);
}
catch (Exception e)
{
out.print("Exception is" +e);
}


Plz help me.
Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 17 2008
Added on Dec 1 2006
7 comments
3,679 views