MessagingException: 501 Syntax: HELO hostname. Very Urgent
843830Dec 1 2006 — edited Aug 20 2008Hi,
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.