<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common Development
and Distribution License("CDDL") (collectively, the "License"). You
may not use this file except in compliance with the License. You can obtain
a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
language governing permissions and limitations under the License.
When distributing the software, include this License Header Notice in each
file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
Sun designates this particular file as subject to the "Classpath" exception
as provided by Sun in the GPL Version 2 section of the License file that
accompanied this code. If applicable, add the following below the License
Header, with the fields enclosed by brackets [] replaced by your own
identifying information: "Portions Copyrighted [year]
[name of copyright owner]"
Contributor(s):
If you wish your version of this file to be governed by only the CDDL or
only the GPL Version 2, indicate your decision by adding "[Contributor]
elects to include this software in this distribution under the [CDDL or GPL
Version 2] license." If you don't indicate a single choice of license, a
recipient has the option to distribute your version of this file under
either the CDDL, the GPL Version 2 or to extend the choice of license to
its licensees as provided above. However, if you add GPL Version 2 code
and therefore, elected the GPL Version 2 license, then the option applies
only if the new code is made subject to such option by the copyright
holder.
@(#)package.html 1.21 07/07/02
-->
</HEAD>
<BODY BGCOLOR="white">
An SMTP protocol provider for the JavaMail API
that provides access to an SMTP server.
Refer to <A HREF="http://www.ietf.org/rfc/rfc821.txt" TARGET="_top">RFC 821</A>
for more information.
<P>
When sending a message, detailed information on each address that
fails is available in an
{@link com.sun.mail.smtp.SMTPAddressFailedException SMTPAddressFailedException}
chained off the top level
{@link javax.mail.SendFailedException SendFailedException}
that is thrown.
In addition, if the <code>mail.smtp.reportsuccess</code> property
is set, an
{@link com.sun.mail.smtp.SMTPAddressSucceededException
SMTPAddressSucceededException}
will be included in the list for each address that is successful.
Note that this will cause a top level
{@link javax.mail.SendFailedException SendFailedException}
to be thrown even though the send was successful.
<P>
The SMTP provider also supports ESMTP
(<A HREF="http://www.ietf.org/rfc/rfc1651.txt" TARGET="_top">RFC 1651</A>).
It can optionally use SMTP Authentication
(<A HREF="http://www.ietf.org/rfc/rfc2554.txt" TARGET="_top">RFC 2554</A>)
using the LOGIN, PLAIN, and DIGEST-MD5 mechanisms
(<A HREF="http://www.ietf.org/rfc/rfc2592.txt" TARGET="_top">RFC 2592</A>
and <A HREF="http://www.ietf.org/rfc/rfc2831.txt" TARGET="_top">RFC 2831</A>).
<P>
To use SMTP authentication you'll need to set the <code>mail.smtp.auth</code>
property (see below) and provide the SMTP Transport
with a username and password when connecting to the SMTP server. You
can do this using one of the following approaches:
<P>
<UL>
<LI>
Provide an Authenticator object when creating your mail Session
and provide the username and password information during the
Authenticator callback.
<P>
Note that the <code>mail.smtp.user</code> property can be set to provide a
default username for the callback, but the password will still need to be
supplied explicitly.
<P>
This approach allows you to use the static Transport <code>send</code> method
to send messages.
</LI>
<P>
<LI>
Call the Transport <code>connect</code> method explicitly with username and
password arguments.
<P>
This approach requires you to explicitly manage a Transport object
and use the Transport <code>sendMessage</code> 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 <code>send</code> method, but supplies the needed username and
password:
<P>
<BLOCKQUOTE><PRE>
Transport tr = session.getTransport("smtp");
tr.connect(smtphost, username, password);
msg.saveChanges(); // don't forget this
tr.sendMessage(msg, msg.getAllRecipients());
tr.close();
</PRE></BLOCKQUOTE>
</LI>
</UL>
<P>
When using DIGEST-MD5 authentication,
you'll also need to supply an appropriate realm;
your mail server administrator can supply this information.
You can set this using the <code>mail.smtp.sasl.realm</code> property,
or the <code>setSASLRealm</code> method on <code>SMTPTransport</code>.
<P>
SMTP can also optionally request Delivery Status Notifications
(<A HREF="http://www.ietf.org/rfc/rfc1891.txt" TARGET="_top">RFC 1891</A>).
The delivery status will typically be reported using
a "multipart/report"
(<A HREF="http://www.ietf.org/rfc/rfc1892.txt" TARGET="_top">RFC 1892</A>)
message type with a "message/delivery-status"
(<A HREF="http://www.ietf.org/rfc/rfc1894.txt" TARGET="_top">RFC 1894</A>)
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 <code>MimeMultipart</code> and <code>MimeMessage</code> objects.
<P>
See below for the properties to enable these features.
<P>
Note also that <strong>THERE IS NOT SUFFICIENT DOCUMENTATION HERE TO USE THESE
FEATURES!!!</strong> 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. <strong>READ THE RFCs FIRST!!!</strong>
<P>
The SMTP protocol provider supports the following properties,
which may be set in the JavaMail <code>Session</code> object.
The properties are always set as strings; the Type column describes
how the string is interpreted. For example, use
<PRE>
props.put("mail.smtp.port", "888");
</PRE>
to set the <CODE>mail.smtp.port</CODE> property, which is of type int.
<P>
<TABLE BORDER>
<TR>
<TH>Name</TH>
<TH>Type</TH>
<TH>Description</TH>
</TR>
<TR>
<TD>mail.smtp.user</TD>
<TD>String</TD>
<TD>Default user name for SMTP.</TD>
</TR>
<TR>
<TD>mail.smtp.host</TD>
<TD>String</TD>
<TD>The SMTP server to connect to.</TD>
</TR>
<TR>
<TD>mail.smtp.port</TD>
<TD>int</TD>
<TD>The SMTP server port to connect to, if the connect() method doesn't
explicitly specify one. Defaults to 25.</TD>
</TR>
<TR>
<TD>mail.smtp.connectiontimeout</TD>
<TD>int</TD>
<TD>Socket connection timeout value in milliseconds.
Default is infinite timeout.</TD>
</TR>
<TR>
<TD>mail.smtp.timeout</TD>
<TD>int</TD>
<TD>Socket I/O timeout value in milliseconds. Default is infinite timeout.</TD>
</TR>
<TR>
<TD>mail.smtp.from</TD>
<TD>String</TD>
<TD>
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.
</TD>
</TR>
<TR>
<TD>mail.smtp.localhost</TD>
<TD>String</TD>
<TD>
Local host name used in the SMTP HELO or EHLO command.
Defaults to <code>InetAddress.getLocalHost().getHostName()</code>.
Should not normally need to
be set if your JDK and your name service are configured properly.
</TD>
</TR>
<TR>
<TD>mail.smtp.localaddress</TD>
<TD>String</TD>
<TD>
Local address (host name) to bind to when creating the SMTP socket.
Defaults to the address picked by the Socket class.
Should not normally need to be set, but useful with multi-homed hosts
where it's important to pick a particular local address to bind to.
</TD>
</TR>
<TR>
<TD>mail.smtp.localport</TD>
<TD>int</TD>
<TD>
Local port number to bind to when creating the SMTP socket.
Defaults to the port number picked by the Socket class.
</TD>
</TR>
<TR>
<TD>mail.smtp.ehlo</TD>
<TD>boolean</TD>
<TD>
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.
</TD>
</TR>
<TR>
<TD>mail.smtp.auth</TD>
<TD>boolean</TD>
<TD>If true, attempt to authenticate the user using the AUTH command.
Defaults to false.</TD>
</TR>
<TR>
<TD>mail.smtp.submitter</TD>
<TD>String</TD>
<TD>The submitter to use in the AUTH tag in the MAIL FROM command.
Typically used by a mail relay to pass along information about the
original submitter of the message.
See also the {@link com.sun.mail.smtp.SMTPMessage#setSubmitter setSubmitter}
method of {@link com.sun.mail.smtp.SMTPMessage SMTPMessage}.
Mail clients typically do not use this.
</TD>
</TR>
<TR>
<TD>mail.smtp.dsn.notify</TD>
<TD>String</TD>
<TD>The NOTIFY option to the RCPT command. Either NEVER, or some
combination of SUCCESS, FAILURE, and DELAY (separated by commas).</TD>
</TR>
<TR>
<TD>mail.smtp.dsn.ret</TD>
<TD>String</TD>
<TD>The RET option to the MAIL command. Either FULL or HDRS.</TD>
</TR>
<TR>
<TD>mail.smtp.allow8bitmime</TD>
<TD>boolean</TD>
<TD>
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.
</TD>
</TR>
<TR>
<TD>mail.smtp.sendpartial</TD>
<TD>boolean</TD>
<TD>
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.
</TD>
</TR>
<TR>
<TD>mail.smtp.sasl.realm</TD>
<TD>String</TD>
<TD>The realm to use with DIGEST-MD5 authentication.</TD>
</TR>
<TR>
<TD>mail.smtp.quitwait</TD>
<TD>boolean</TD>
<TD>
If set to false, the QUIT command is sent
and the connection is immediately closed.
If set to true (the default), causes the transport to wait
for the response to the QUIT command.
</TD>
</TR>
<TR>
<TD>mail.smtp.reportsuccess</TD>
<TD>boolean</TD>
<TD>
If set to true, causes the transport to include an
{@link com.sun.mail.smtp.SMTPAddressSucceededException
SMTPAddressSucceededException}
for each address that is successful.
Note also that this will cause a
{@link javax.mail.SendFailedException SendFailedException}
to be thrown from the
{@link com.sun.mail.smtp.SMTPTransport#sendMessage sendMessage}
method of
{@link com.sun.mail.smtp.SMTPTransport SMTPTransport}
even if all addresses were correct and the message was sent
successfully.
</TD>
</TR>
<TR>
<TD>mail.smtp.socketFactory.class</TD>
<TD>String</TD>
<TD>
If set, specifies the name of a class that implements the
<code>javax.net.SocketFactory</code> interface. This class
will be used to create SMTP sockets.
</TD>
</TR>
<TR>
<TD>mail.smtp.socketFactory.fallback</TD>
<TD>boolean</TD>
<TD>
If set to true, failure to create a socket using the specified
socket factory class will cause the socket to be created using
the <code>java.net.Socket</code> class.
Defaults to true.
</TD>
</TR>
<TR>
<TD>mail.smtp.socketFactory.port</TD>
<TD>int</TD>
<TD>
Specifies the port to connect to when using the specified socket
factory.
If not set, the default port will be used.
</TD>
</TR>
<TR>
<TD>mail.smtp.mailextension</TD>
<TD>String</TD>
<TD>
Extension string to append to the MAIL command.
The extension string can be used to specify standard SMTP
service extensions as well as vendor-specific extensions.
Typically the application should use the
{@link com.sun.mail.smtp.SMTPTransport SMTPTransport}
method {@link com.sun.mail.smtp.SMTPTransport#supportsExtension
supportsExtension}
to verify that the server supports the desired service extension.
See <A HREF="http://www.ietf.org/rfc/rfc1869.txt" TARGET="_top">RFC 1869</A>
and other RFCs that define specific extensions.
</TD>
</TR>
<TR>
<TD>mail.smtp.starttls.enable</TD>
<TD>boolean</TD>
<TD>
If true, enables the use of the <code>STARTTLS</code> command (if
supported by the server) to switch the connection to a TLS-protected
connection before issuing any login commands. Note that an appropriate
trust store must configured so that the client will trust the server's
certificate.
Defaults to false.
</TD>
</TR>
<TR>
<TD>mail.smtp.userset</TD>
<TD>boolean</TD>
<TD>
If set to true, use the RSET command instead of the NOOP command
in the {@link javax.mail.Transport#isConnected isConnected} method.
In some cases sendmail will respond slowly after many NOOP commands;
use of RSET avoids this sendmail issue.
Defaults to false.
</TD>
</TR>
<TR>
<TD>mail.smtp.ssl.protocols</TD>
<TD>string</TD>
<TD>
Specifies the SSL protocols that will be enabled for SSL connections.
The property value is a whitespace separated list of tokens acceptable
to the <code>javax.net.ssl.SSLSocket.setEnabledProtocols</code> method.
</TD>
</TR>
<TR>
<TD>mail.smtp.ssl.ciphersuites</TD>
<TD>string</TD>
<TD>
Specifies the SSL cipher suites that will be enabled for SSL connections.
The property value is a whitespace separated list of tokens acceptable
to the <code>javax.net.ssl.SSLSocket.setEnabledCipherSuites</code> method.
</TD>
</TR>
</TABLE>
<P>
In general, applications should not need to use the classes in this
package directly. Instead, they should use the APIs defined by
<code>javax.mail</code> package (and subpackages). Applications should
never construct instances of <code>SMTPTransport</code> directly.
Instead, they should use the
<code>Session</code> method <code>getTransport</code> to acquire an
appropriate <code>Transport</code> object.
<P>
<strong>WARNING:</strong> The APIs unique to this package should be
considered <strong>EXPERIMENTAL</strong>. They may be changed in the
future in ways that are incompatible with applications using the
current APIs.
</BODY>
</HTML>
|