1 package com.ozacc.mail; 2 3 import javax.mail.internet.MimeMessage; 4 5 /*** 6 * SMTPサーバとの接続、切断を任意のタイミングで行いたい場合に使用するSendMailインターフェース。 7 * <p> 8 * 大量メール配信で、MailやMimeMessageの配列を用意するとメモリを圧迫してしまう場合などに使用します。<br> 9 * 接続のクローズを忘れないように注意してください。 10 * <p> 11 * このインターフェース実装クラスのインスタンスは、メールサーバとの接続を保持するため、 12 * スレッドセーフではありません。<br> 13 * DIコンテナでの使用の際はシングルトンでインスタンスを取得しないように注意してください。 14 * 15 * @since 1.0 16 * @author Tomohiro Otsuka 17 * @version $Id: SendMailPro.java,v 1.2.2.1 2004/11/25 08:02:27 otsuka Exp $ 18 */ 19 public interface SendMailPro { 20 21 /*** 22 * SMTPサーバに接続します。 23 * 24 * @throws MailException 25 */ 26 void connect() throws MailException; 27 28 /*** 29 * SMTPサーバとの接続をクローズします。 30 * 接続していない時にこのメソッドを呼んでも何も行いません。 31 * 32 * @throws MailException 33 */ 34 void disconnect() throws MailException; 35 36 /*** 37 * 指定されたMimeMessageを送信します。SMTPサーバに接続していない場合は例外をスローします。 38 * 39 * @param mimeMessage 40 * @throws MailException 41 */ 42 void send(MimeMessage mimeMessage) throws MailException; 43 44 /*** 45 * 指定されたMailを送信します。SMTPサーバに接続していない場合は例外をスローします。 46 * 47 * @param mail 48 * @throws MailException 49 */ 50 void send(Mail mail) throws MailException; 51 52 }