This approach requires you to explicitly manage a Transport object
and use the Transport sendMessage method to send the message.
The transport.java demo program demonstrates how to manage a Transport
object. The following is roughly equivalent to the static
Transport send method, but supplies the needed username and
password:

You'll also need to supply an appropriate realm when using DIGEST-MD5
authentication; your mail server administrator can supply this information.
You can set this using the mail.smtp.saslrealm property,
or the setSASLRealm method on SMTPTransport.

SMTP can also optionally request Delivery Status Notifications (RFC 1891).
The delivery status will typically be reported using
a "multipart/report"
(RFC 1892) message type with a "message/delivery-status"
(RFC 1894) part.
JavaMail does not currently provide direct support for these new MIME types,
but you can process them as any other "multipart" or "message" content,
using MimeMultipart and MimeMessage objects.

See below for the properties to enable these features.

Note also that THERE IS NOT SUFFICIENT DOCUMENTATION HERE TO USE THESE
FEATURES!!! You will need to read the appropriate RFCs mentioned above
to understand what these features do and how to use them. Don't just
start setting properties and then complain to us when it doesn't work
like you expect it to work. READ THE RFCs FIRST!!!

The SMTP protocol provider supports the following properties,
which may be set in the JavaMail Session object.
The properties are always set as strings; the Type column describes
how the string is interpreted. For example, use

Email address to use for SMTP MAIL command. This sets the envelope
return address. Defaults to msg.getFrom() or
InternetAddress.getLocalAddress(). NOTE: mail.smtp.user was previously
used for this.

mail.smtp.localhost

String

Local host name. Defaults to
InetAddress.getLocalHost().getHostName(). Should not normally need to
be set if your JDK and your name service are configured properly.

mail.smtp.ehlo

boolean

If false, do not attempt to sign on with the EHLO command. Defaults to
true. Normally failure of the EHLO command will fallback to the HELO
command; this property exists only for servers that don't fail EHLO
properly or don't implement EHLO properly.

mail.smtp.auth

boolean

If true, attempt to authenticate the user using the AUTH command.
Defaults to false.

mail.smtp.dsn.notify

String

The NOTIFY option to the RCPT command. Either NEVER, or some
combination of SUCCESS, FAILURE, and DELAY (separated by commas).

mail.smtp.dsn.ret

String

The RET option to the MAIL command. Either FULL or HDRS.

mail.smtp.allow8bitmime

boolean

If set to true, and the server supports the 8BITMIME extension, text
parts of messages that use the "quoted-printable" or "base64" encodings
are converted to use "8bit" encoding if they follow the RFC2045 rules
for 8bit text.

mail.smtp.sendpartial

boolean

If set to true, and a message has some valid and some invalid
addresses, send the message anyway, reporting the partial failure with
a SendFailedException. If set to false (the default), the message is
not sent to any of the recipients if there is an invalid recipient
address.

mail.smtp.saslrealm

String

The realm to use with DIGEST-MD5 authentication.

mail.smtp.quitwait

boolean

If set to true, causes the transport to wait for the response to the
QUIT command. If set to false (the default), the QUIT command is sent
and the connection is immediately closed. (NOTE: The default may change
in the next release.)

In general, applications should not need to use the classes in this
package directly. Instead, they should use the APIs defined by
javax.mail package (and subpackages). Applications should
never construct instances of SMTPTransport directly.
Instead, they should use the
Session method getTransport to acquire an
appropriate Transport object.

* Reference brought to you by
Bugzero, it's more than just bug tracking software!