How can I add functionality for sending email messages from our struts application?
The JavaMail API (http://java.sun.com/products/javamail) provides an easy-to-use framework for building email senders and receivers over many different protocols, such as IMAP, MAPI, POP, POP3, and SMTP. The JavaMail API package can be downloaded separately and is also available as part of the Java 2 Enterprise Edition (J2EE) platform.
The following steps illustrate how easy the JavaMail API makes it to send email messages:
1) Import the JavaMail APIs:
2) Create the mail session:
Properties props = new Properties();
Session mailSession =
3) Create the email message:
MimeMessage msg = new MimeMessage(mailSession);
msg.setSubject("This is the email message subject");
msg.setText("This is the email message body");
4) Send the message:
Dig Deeper on Topics Archive
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.