Sending a Simple Email

This section introduces you to the core Java classes you need to send an email message. Specifically, you will use these classes to write an example mail program that accepts an SMTP host and mail recipient from the command line, and then sends a plain text email to that recipient.

Although the application uses the command line, you can modify the code for use in other situations if you want.

Creating a JavaMail Session

This application uses classes from the javax.mail package and the javax.mail.internet package. The javax.mail package provides classes that model a mail system, for example all mail systems require messages to contain a message body. The javax.mail.internet package provides classes that are specific to Internet ...

Get Sams Teach Yourself J2EE™ in 21 Days, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.