cancel
Showing results for 
Search instead for 
Did you mean: 

Java mail API doesn't work !!

Former Member
0 Kudos

Hi,

I created an application to send mail. I would like my application to send mail to a specific recipient address that will always be the same. The problem is that the mail is never sent and I never get any errors. Here is my source code:

try {
	//	enter the mail host name here
	String host = "10.139.16.13";
			
	//	Get system properties
	Properties props = System.getProperties();
			
	//	Setup mail server
	props.put("mail.smtp.host", host);
			
	//	Setup authentication, get session
	Authenticator auth = new PopupAuthenticator();
			
	//Session session = Session.getInstance(props, auth);
	Session session = Session.getDefaultInstance(props, null);
			
	//	Define message
	MimeMessage message = new MimeMessage(session);
			
	Address fromAddress = new InternetAddress("address at address.com", "From me");
	Address toAddress = new InternetAddress("address at address.com");
			
	message.setFrom(fromAddress);
	message.addRecipient(Message.RecipientType.TO,toAddress);
	message.setSubject("Notification");
	message.setText(wdContext.currentPopupNodeElement().getUserRequest());
			
	//	Send message
	Transport.send(message);
} catch (Exception e) {
	System.out.println("Exception while sending mail" + e.getMessage());
	e.printStackTrace();
}

Any idea ?

Thanks for your help...

Thibault

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Sorry I found the solution on an other thread.

Thanks for your help.

Former Member
0 Kudos

Hi,

Did you checked the log for any errors

catch (Exception e) {

System.out.println("Exception while sending mail" + e.getMessage());

e.printStackTrace();

Or else add the following line in your exception handler and check whether their is any error or not.

wdComponentAPI.getMessageManager().reportException(e.getMessage());

Regards

Ayyapparaj