
org.glowroot.agent.shaded.javax.mail.package.html Maven / Gradle / Ivy
Show all versions of glowroot-agent-it-harness Show documentation
The JavaMailTM API
provides classes that model a mail system.
The javax.mail
package defines classes that are common to
all mail systems.
The javax.mail.internet
package defines classes that are specific
to mail systems based on internet standards such as MIME, SMTP, POP3, and IMAP.
The JavaMail API includes the javax.mail
package and subpackages.
For an overview of the JavaMail API, read the
JavaMail specification.
The code to send a plain text message can be as simple as the following:
Properties props = new Properties();
props.put("mail.smtp.host", "my-mail-server");
Session session = Session.getInstance(props, null);
try {
MimeMessage msg = new MimeMessage(session);
msg.setFrom("[email protected]");
msg.setRecipients(Message.RecipientType.TO,
"[email protected]");
msg.setSubject("JavaMail hello world example");
msg.setSentDate(new Date());
msg.setText("Hello, world!\n");
Transport.send(msg, "[email protected]", "my-password");
} catch (MessagingException mex) {
System.out.println("send failed, exception: " + mex);
}
The JavaMail download bundle contains many more complete examples
in the "demo" directory.
Don't forget to see the
JavaMail API FAQ
for answers to the most common questions.
The
JavaMail web site
contains many additional resources.
Properties
The JavaMail API supports the following standard properties,
which may be set in the Session
object, or in the
Properties
object used to create the Session
object.
The properties are always set as strings; the Type column describes
how the string is interpreted. For example, use
props.put("mail.debug", "true");
to set the mail.debug
property, which is of type boolean.
The following properties are supported by the reference implementation (RI) of
JavaMail, but are not currently a required part of the specification.
The names, types, defaults, and semantics of these properties may
change in future releases.
The JavaMail API also supports several System properties;
see the {@link javax.mail.internet} package documentation
for details.
The JavaMail reference
implementation includes protocol providers in subpackages of
com.sun.mail
. Note that the APIs to these protocol
providers are not part of the standard JavaMail API. Portable
programs will not use these APIs.
Nonportable programs may use the APIs of the protocol providers
by (for example) casting a returned Folder
object to a
com.sun.mail.imap.IMAPFolder
object. Similarly for
Store
and Message
objects returned from the
standard JavaMail APIs.
The protocol providers also support properties that are specific to
those providers. The package documentation for the
{@link com.sun.mail.imap IMAP}, {@link com.sun.mail.pop3 POP3},
and {@link com.sun.mail.smtp SMTP} packages provide details.
In addition to printing debugging output as controlled by the
{@link javax.mail.Session Session} configuration, the current
implementation of classes in this package log the same information using
{@link java.util.logging.Logger} as described in the following table:
Logger Name
Logging Level
Purpose
javax.mail
CONFIG
Configuration of the Session
javax.mail
FINE
General debugging output