cancel
Showing results for 
Search instead for 
Did you mean: 

Mail Service Activation

Former Member
0 Kudos

Hi Experts,

What are the service and jar files required to run mail service application. I deployed one application but mailing is not working..

What are codes required to do so????....

Please share some links.

Thanks

Nitu

Accepted Solutions (1)

Accepted Solutions (1)

former_member192434
Active Contributor
0 Kudos

Hi

you can you this sample code, which is working in java.

try {
 
	Properties props = new Properties();
	props.put("mail.transport.protocol", "smtp");
	props.put("mail.smtp.host", SMTP_HOST_NAME);
	props.put("mail.smtp.auth", "true");
	props.put("mail.smtp.port", "26");
 
	Authenticator auth = new SMTPAuthenticator();
	Session session = Session.getDefaultInstance(props, auth);
 
	session.setDebug(true);
 
	
	MimeMessage message = new MimeMessage(session);
	message.setSubject("Testing javamail plain");
	message.setContent("This is a test", "text/plain");
	message.setFrom(new InternetAddress("from@something"));
	message.setRecipient(
		Message.RecipientType.TO,
		new InternetAddress("to@something"));
		
	Transport transport = session.getTransport();
	//Transport.send(message);
	transport.connect();
	transport.sendMessage(
		message,
		message.getRecipients(Message.RecipientType.TO));
	transport.close();
} catch (MessagingException exc) {
	exc.printStackTrace(out);
} catch (RuntimeException exc){
	exc.printStackTrace(out);
}

For more check this link

[Implementing Email function.|http://fisheye5.cenqua.com/browse/glassfish/mail/src/java/com/sun/mail/smtp/SMTPTransport.java?r=1.13#l38*This]

Answers (2)

Answers (2)

Former Member
0 Kudos

Have you added mail.jar file to you application and classpath?

If possible run through the FAQ's on Java Mail API here - http://java.sun.com/products/javamail/FAQ.html

Thanks,

GLM

Former Member
0 Kudos

This message was moderated.