Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.mail.smtp
Class SMTPTransport

    java.lang.Object
      |
      +--javax.mail.Service
            |
            +--javax.mail.Transport
                  |
                  +--com.sun.mail.smtp.SMTPTransport

public class SMTPTransport
extends Transport

This class implements the Transport abstract class using SMTP for message submission and transport. See the com.sun.mail.smtp package documentation for further information on the SMTP protocol provider.

See Also:
  `ConnectionEvent`, `TransportEvent`

Fields inherited from class javax.mail.Service
`debug, session, url`

Constructor Summary
`SMTPTransport(Session session, URLName urlname)` Constructor

Method Summary
`void` | `close()` Close the server and terminate its connection
`void` | `connect()` A generic connect method that takes no parameters.
`protected void` | `finalize()` Stop the event dispatcher thread so the queue can be garbage collected.
`java.lang.String` | `getSASLRealm()` Gets the SASL realm to be used for DIGEST-MD5 authentication.
`boolean` | `isConnected()` Check whether the transport is connected.
`protected boolean` | `protocolConnect(java.lang.String host, int port, java.lang.String user, java.lang.String passwd)` Performs the actual protocol-specific connection attempt.
`void` | `sendMessage(Message message, Address[] addresses)` Send the Message to the specified list of addresses.
`void` | `setSASLRealm(java.lang.String saslRealm)` Sets the SASL realm to be used for DIGEST-MD5 authentication.

Methods inherited from class javax.mail.Transport
`addTransportListener, notifyTransportListeners, removeTransportListener, send, send`

Methods inherited from class javax.mail.Service
`addConnectionListener, connect, connect, getURLName, notifyConnectionListeners, queueEvent, removeConnectionListener, setConnected, setURLName, toString`

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### SMTPTransport

    public SMTPTransport(Session session,
                         URLName urlname)

  Constructor

Method Detail

### connect

    public void connect()
                 throws MessagingException

  Description copied from class: `Service`
  A generic connect method that takes no parameters. Subclasses can implement the appropriate authentication schemes. Subclasses that need additional information might want to use some properties or might get it interactively using a popup window.

  If the connection is successful, an "open" `ConnectionEvent` is delivered to any `ConnectionListeners` on this service.

  Most clients should just call this method to connect to the service.

  It is an error to connect to an already connected service.

  The implementation provided here simply calls the following `connect(String, String, String)` method with nulls.

  Overrides:
    `connect` in class `Service`
  Following copied from class: `javax.mail.Service`
  Throws:
    `AuthenticationFailedException` - for authentication failures
    `MessagingException` - for other failures
    `IllegalStateException` - if the service is already connected
  See Also:
    `ConnectionEvent`

### getSASLRealm

    public java.lang.String getSASLRealm()

  Gets the SASL realm to be used for DIGEST-MD5 authentication.
  Returns:
    the name of the realm to use for SASL authentication.

### setSASLRealm

    public void setSASLRealm(java.lang.String saslRealm)

  Sets the SASL realm to be used for DIGEST-MD5 authentication.
  Parameters:
    `saslRealm` - the name of the realm to use for SASL authentication.

### protocolConnect

    protected boolean protocolConnect(java.lang.String host,
                                      int port,
                                      java.lang.String user,
                                      java.lang.String passwd)
                               throws MessagingException

  Performs the actual protocol-specific connection attempt. Will attempt to connect to "localhost" if the host was null.

  Unless mail.smtp.ehlo is set to false, we'll try to identify ourselves using the ESMTP command EHLO. If mail.smtp.auth is set to true, we insist on having a username and password, and will try to authenticate ourselves if the server supports the AUTH extension (RFC 2554).

  Overrides:
    `protocolConnect` in class `Service`
  Parameters:
    `host` - the name of the host to connect to
    `port` - the port to use (-1 means use default port)
    `user` - the name of the user to login as
    `password` - the user's password
  Returns:
    true if connection successful, false if authentication failed
  Throws:
    `MessagingException` - for non-authentication failures

### sendMessage

    public void sendMessage(Message message,
                            Address[] addresses)
                     throws MessagingException,
                            SendFailedException

  Send the Message to the specified list of addresses.

  If all the `addresses` succeed the SMTP check using the `RCPT TO:` command, we attempt to send the message. A TransportEvent of type MESSAGE_DELIVERED is fired indicating the successful submission of a message to the SMTP host.

  If some of the `addresses` fail the SMTP check, and the `mail.stmp.sendpartial` property is not set, sending is aborted. The TransportEvent of type MESSAGE_NOT_DELIVERED is fired containing the valid and invalid addresses. The SendFailedException is also thrown.

  If some of the `addresses` fail the SMTP check, and the `mail.stmp.sendpartial` property is set to true, the message is sent. The TransportEvent of type MESSAGE_PARTIALLY_DELIVERED is fired containing the valid and invalid addresses. The SendFailedException is also thrown.

  MessagingException is thrown if the message can't write out an RFC822-compliant stream using its `writeTo` method.

  Overrides:
    `sendMessage` in class `Transport`
  Parameters:
    `message` - The MimeMessage to be sent
    `address` - List of addresses to send this message to
  Throws:
    `SendFailedException` - if the send failed because of invalid addresses.
    `MessagingException` - if the connection is dead or not in the connected state or if the message is not a MimeMessage.
  See Also:
    `TransportEvent`

### close

    public void close()
               throws MessagingException

  Close the server and terminate its connection
  Overrides:
    `close` in class `Service`
  Following copied from class: `javax.mail.Service`
  Throws:
    `MessagingException` - for errors while closing
  See Also:
    `ConnectionEvent`

### isConnected

    public boolean isConnected()

  Check whether the transport is connected. Override superclass method, to actually ping our server connection.
  Overrides:
    `isConnected` in class `Service`
  Following copied from class: `javax.mail.Service`
  Returns:
    true if the service is connected, false if it is not connected

### finalize

    protected void finalize()
                     throws java.lang.Throwable

  Description copied from class: `Service`
  Stop the event dispatcher thread so the queue can be garbage collected.
  Overrides:
    `finalize` in class `Service`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD