Jakarta Mail2.01.61.5
This feature allows applications to use the Jakarta Mail 2.0 API.
Enabling this feature
To enable the Jakarta Mail 2.0 feature, add the following element declaration into your server.xml
file, inside the featureManager
element:
<feature>mail-2.0</feature>
Example
Send email to and receive email from applications
You can call the Jakarta Mail libraries in any application that runs on the server to send and receive emails. Create a jakarta.mail.Session
object by adding and configuring a mailSession
element. To enable the following configuration, in addition to enabling the Jakarta Mail feature, you must also enable the Java Naming and Directory Interface (JNDI) feature in your server.xml
file:
<mailSession>
<mailSessionID>gmailSMTPSession</mailSessionID>
<jndiName>ExampleMail/SMTPSender/gmailSMTPSession</jndiName>
<description>My Gmail SMTP Session</description>
<storeProtocol>imaps</storeProtocol>
<transportProtocol>smtp</transportProtocol>
<host>smtp.gmail.com</host>
<user>[email protected]</user>
<password>yourpassword</password>
<from>[email protected]</from>
<property name="mail.imap.host" value="imap.gmail.com" />
<property name="mail.smtp.port" value="587" />
<property name="mail.smtp.auth" value="true" />
<property name="mail.smtp.starttls.enable" value="true" />
</mailSession>
This example mail session is configured so that it can be used for both the Simple Mail Transfer Protocol (SMTP) and the Internet Message Access Protocol (IMAP) on Gmail. After you configure the mailSession
element, the mail session is created and injected by using JNDI. The name of the WAR file is ExampleMail
, the class name is SMTPSender
, and the name of the jakarta.mail.Session
object is gmailSMTPSession
. If you use the standard JNDI context, java:comp/env/mail/gmailSMTPSession
, specify the jndiName
attribute as jndiName="mail/gmailSMTPSession"
.
Standard API packages provided by this feature
jakarta.mail
jakarta.mail.event
jakarta.mail.internet
jakarta.mail.search
jakarta.mail.util
Third-party API packages provided by this feature
com.sun.mail
com.sun.mail.auth
com.sun.mail.handlers
com.sun.mail.iap
com.sun.mail.imap
com.sun.mail.imap.protocol
com.sun.mail.pop3
com.sun.mail.smtp
com.sun.mail.util
com.sun.mail.util.logging