Hi
I have written a code for sending a mail, it was working fine before and now it hangs at tranport.send().
Can any one help, here my codeInline Code Example Here
try {
System.out.println("Sending Email initiated...");
Properties properties = System.getProperties();
properties.put("mail.smtp.auth", "false");
properties.put("mail.smtp.starttls.enable", "true");
properties.put("mail.smtp.host", _host);
properties.put("mail.smtp.port", _port);
properties.put("mail.smtp.connectiontimeout", "100000");
properties.put("mail.smtp.timeout", "100000");
Session session = Session.getInstance(properties,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(_emailfrom, "");
}
});
MimeMessage message = new MimeMessage(session);
log.debug("Sending Email from: " + _emailfrom);
// System.out.println("Sending Email from: " + _emailfrom);
// Set From: header field of the header.
message.setFrom(new InternetAddress(_emailfrom));
to_recep = _toreceipients.split(",");
if (to_recep.length > 0) {
for (int i = 0; i < to_recep.length; i++) {
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to_recep[i]));
}
}
cc_recep = _ccreceipients.split(",");
if (cc_recep.length > 0) {
for (int i = 0; i < cc_recep.length; i++) {
if (cc_recep[i].length() > 2)
message.addRecipient(Message.RecipientType.CC,
new InternetAddress(cc_recep[i]));
}
}
log.debug("Setting Subject & Content of Email");
message.setSubject(MSG_SUBJECT + " " + getCurrentDate());
message.setText(_message, "utf-8", "html");
log.debug("Going to send an Email ....");
// System.out.println("Going to send an Email ....");
// Send message
Transport.send(message);
log.debug("Email send successfully....");
// System.out.println("Email send successfully....");
} catch (MessagingException mex) {
mex.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
log.debug(e.getMessage());
}