Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email not working

Status
Not open for further replies.

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?
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();
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top