I am using the below snippet to send the mail:
Properties props =
new Properties();props.put(
"mail.smtp.debug", true);props.put(
"mail.smtp.host", mailhost);Session session = Session.getDefaultInstance(props,
null);
try {
MimeMessage msg =
new MimeMessage(session);msg.setFrom(
new InternetAddress(from));
msg.addRecipients(MimeMessage.RecipientType.
TO, address);msg.setSubject(subject);
msg.setSentDate(
new Date());msg.setContent(msgBody,
"text/plain");Transport.send(msg);
When I used a valid mail host then it is working but when I am using the value of mail host as "localhost", it is not working. So, in an environment where local host can be used as the mail host only, what needs to be done. Can any one please help me out ?