com.sun.mail.smtp
クラス SMTPTransport

java.lang.Object
  上位を拡張 javax.mail.Service
      上位を拡張 javax.mail.Transport
          上位を拡張 com.sun.mail.smtp.SMTPTransport
直系の既知のサブクラス:
SMTPSSLTransport

public class SMTPTransport
extends Transport

このクラスは、メッセージサブミッションと転送の為に SMTP を使用する Transport 抽象クラスを実装します。 SMTP プロトコルプロバイダの詳細に関しては jp.sourceforge.livez.mail.smtp パッケージドキュメンテーションを参照して下さい。

関連項目:
ConnectionEvent, TransportEvent

フィールドの概要
 
クラス javax.mail.Service から継承されたフィールド
debug, session, url
 
コンストラクタの概要
SMTPTransport(Session session, URLName urlname)
          コンストラクタです。
SMTPTransport(Session session, URLName urlname, String name, int defaultPort, boolean isSSL)
          このクラスと SMTPSSLTransport サブクラスによって使用されるコンストラクタです。
 
メソッドの概要
 void close()
          サーバを閉じ、接続を終了させます。
 void connect(Socket socket)
          Start the SMTP protocol on the given socket, which was already connected by the caller.
protected  void finalize()
          キューがガベージコレクト可能になるように、イベントディスパッチャスレッドを停止します。
 String getExtensionParameter(String ext)
          Return the parameter the server provided for the specified service extension, or null if the extension isn't supported.
 String getLastServerResponse()
          Return the last response we got from the server.
 boolean getReportSuccess()
          Should we report even successful sends by throwing an exception?
 String getSASLRealm()
          DIGEST-MD5 認証に使用される SASL レルムを取得します。
 boolean getStartTLS()
          Should we use the STARTTLS command to secure the connection if the server supports it?
 boolean isConnected()
          Check whether the transport is connected.
protected  boolean protocolConnect(String host, int port, String user, String passwd)
          実際のプロトコル特有の接続試みを実行します。
 void sendMessage(Message message, Address[] addresses)
          Message を指定されたリストのアドレスに送信します。
 void setLocalHost(String localHostName)
          EHLO と HELO コマンドを使用する時のローカルホストの名前を設定します。
 void setReportSuccess(boolean reportSuccess)
          Set whether successful sends should be reported by throwing an exception.
 void setSASLRealm(String saslRealm)
          SASL レルムに DIGEST-MD5 認証が使用される様に設定します。
 void setStartTLS(boolean useStartTLS)
          Set whether the STARTTLS command should be used.
 boolean supportsExtension(String ext)
          Return true if the SMTP server supports the specified service extension.
 
クラス javax.mail.Transport から継承されたメソッド
addTransportListener, notifyTransportListeners, removeTransportListener, send, send
 
クラス javax.mail.Service から継承されたメソッド
addConnectionListener, connect, connect, connect, getURLName, notifyConnectionListeners, queueEvent, removeConnectionListener, setConnected, setURLName, toString
 
クラス java.lang.Object から継承されたメソッド
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

コンストラクタの詳細

SMTPTransport

public SMTPTransport(Session session,
                     URLName urlname)
コンストラクタです。


SMTPTransport

public SMTPTransport(Session session,
                     URLName urlname,
                     String name,
                     int defaultPort,
                     boolean isSSL)
このクラスと SMTPSSLTransport サブクラスによって使用されるコンストラクタです。

メソッドの詳細

setLocalHost

public final void setLocalHost(String localHostName)
EHLO と HELO コマンドを使用する時のローカルホストの名前を設定します。

導入されたバージョン:
JavaMail 1.3.1

connect

public final void connect(Socket socket)
                   throws MessagingException
Start the SMTP protocol on the given socket, which was already connected by the caller. Useful for implementing the SMTP ATRN command (RFC 2645) where an existing connection is used when the server reverses roles and becomes the client.

例外:
MessagingException
導入されたバージョン:
JavaMail 1.3.3

getSASLRealm

public final String getSASLRealm()
DIGEST-MD5 認証に使用される SASL レルムを取得します。

戻り値:
SASL 認証に使用するレルムの名前
導入されたバージョン:
JavaMail 1.3.1

setSASLRealm

public final void setSASLRealm(String saslRealm)
SASL レルムに DIGEST-MD5 認証が使用される様に設定します。

パラメータ:
saslRealm - SASL 認証に使用するレルムの名前
導入されたバージョン:
JavMail 1.3.1

getReportSuccess

public final boolean getReportSuccess()
Should we report even successful sends by throwing an exception? If so, a SendFailedException will always be thrown and an SMTPAddressSucceededException will be included in the exception chain for each successful address, along with the usual SMTPAddressFailedException for each unsuccessful address.

戻り値:
true if an exception will be thrown on successful sends.
導入されたバージョン:
JavaMail 1.3.2

setReportSuccess

public final void setReportSuccess(boolean reportSuccess)
Set whether successful sends should be reported by throwing an exception.

パラメータ:
reportSuccess - should we throw an exception on success?
導入されたバージョン:
JavaMail 1.3.2

getStartTLS

public final boolean getStartTLS()
Should we use the STARTTLS command to secure the connection if the server supports it?

戻り値:
true if the STARTTLS command will be used
導入されたバージョン:
JavaMail 1.3.2

setStartTLS

public final void setStartTLS(boolean useStartTLS)
Set whether the STARTTLS command should be used.

パラメータ:
useStartTLS - should we use the STARTTLS command?
導入されたバージョン:
JavaMail 1.3.2

getLastServerResponse

public final String getLastServerResponse()
Return the last response we got from the server. A failed send is often followed by an RSET command, but the response from the RSET command is not saved. Instead, this returns the response from the command before the RSET command.

戻り値:
last response from server
導入されたバージョン:
JavaMail 1.3.2

protocolConnect

protected final boolean protocolConnect(String host,
                                        int port,
                                        String user,
                                        String passwd)
                                 throws MessagingException
実際のプロトコル特有の接続試みを実行します。 ホストが null の場合、"localhost" に接続するのを試みます。

mail.smtp.ehlo が false に設定されない場合、 ESMTP コマンド 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).

オーバーライド:
クラス Service 内の protocolConnect
パラメータ:
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
passwd - the user's password
戻り値:
true if connection successful, false if authentication failed
例外:
MessagingException - for non-authentication failures

sendMessage

public final void sendMessage(Message message,
                              Address[] addresses)
                       throws MessagingException,
                              SendFailedException
Message を指定されたリストのアドレスに送信します。

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 SMTPSendFailedException is also thrown.

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

定義:
クラス Transport 内の sendMessage
パラメータ:
message - 送信される MimeMessage
addresses - このメッセージの送信先アドレスのリスト
例外:
SMTPSendFailedException - if the send failed because of an SMTP command error
SendFailedException - 無効なアドレスの為に送信が失敗した場合
MessagingException - 接続が終了している場合、又は接続状態にない場合、又はメッセージが MimeMessage ではない場合
関連項目:
TransportEvent

close

public final void close()
                 throws MessagingException
サーバを閉じ、接続を終了させます。

オーバーライド:
クラス Service 内の close
例外:
MessagingException - クローズ中のエラーの場合
関連項目:
ConnectionEvent

isConnected

public final boolean isConnected()
Check whether the transport is connected. Override superclass method, to actually ping our server connection.

オーバーライド:
クラス Service 内の isConnected
戻り値:
サービスが接続されている場合は true、接続されていない場合は false

finalize

protected void finalize()
                 throws Throwable
クラス Service の記述:
キューがガベージコレクト可能になるように、イベントディスパッチャスレッドを停止します。

オーバーライド:
クラス Service 内の finalize
例外:
Throwable

supportsExtension

public boolean supportsExtension(String ext)
Return true if the SMTP server supports the specified service extension. Extensions are reported as results of the EHLO command when connecting to the server. See RFC 1869 and other RFCs that define specific extensions.

パラメータ:
ext - the service extension name
戻り値:
true if the extension is supported
導入されたバージョン:
JavaMail 1.3.2

getExtensionParameter

public final String getExtensionParameter(String ext)
Return the parameter the server provided for the specified service extension, or null if the extension isn't supported.

パラメータ:
ext - the service extension name
戻り値:
the extension parameter
導入されたバージョン:
JavaMail 1.3.2