florida1987
IS-IT--Management
- Dec 9, 2007
- 26
I have this email method that worked about 2 months ago. .
Today when I used it, it didnt send any emails and I got no error messages on the web page. Where or how can I find out what the issue is or why its not working?
Today when I used it, it didnt send any emails and I got no error messages on the web page. Where or how can I find out what the issue is or why its not working?
Code:
public static void send(String smtpServer, String to, String from, String body)
{
try
{
Properties props = System.getProperties();
props.put("mail.smtp.host", smtpServer);
Session session = Session.getDefaultInstance(props, null);
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to, false));
msg.setSubject("Test Mail thru java");
msg.setContent(body,"text/plain");
msg.setSentDate(new Date());
Transport.send(msg);
System.out.println("Email message.");
}
catch (Exception ex)
{
ex.printStackTrace();
}