Using Javamail to Send Emails (Includes SMTP Auth and Attachment Support)
Last night I presented my article discussing how to use JavaMail to check a POP3 mail account and retrieve its messages. Tonight I am going to follow that up with a summary of my EmailDelivery class. This is a simple class I wrote to help me easily send emails from my Java applications. A few highlights of the class are that it:
- Supports relaying through SMTP servers that require authentication.
- Has convenience methods for easily adding file attachments.
- Has a method to set the message priority (high, normal, low).
- Allows you to easily set the to, from, cc, and bcc email addresses. Also supports passing in a comma separated list into any of these methods and have it parsed automatically for easy sending to multiple recipients.
- Allows you to easily add header name/value pairs in the message.
- Suppports easily setting the value stored in the Message-ID header tag of the message.