org.clapper.util.mail
Class SMTPEmailTransport

java.lang.Object
  extended by org.clapper.util.mail.SMTPEmailTransport
All Implemented Interfaces:
EmailTransport

public class SMTPEmailTransport
extends java.lang.Object
implements EmailTransport

SMTPEmailTransport defines a class that sends EmailMessage objects via the Simple Mail Transfer Protocol (SMTP). You instantiate an SMTPEmailTransport object by specifying the SMTP host to be used to send messages, and you then use the object to send EmailMessage objects.

Version:
$Revision: 6735 $
Author:
Copyright © 2004-2007 Brian M. Clapper
See Also:
EmailMessage

Constructor Summary
SMTPEmailTransport()
          Constructs a new SMTPEmailTransport object that will use the local host as its SMTP server.
SMTPEmailTransport(java.lang.String smtpHost)
          Constructs a new SMTPEmailTransport object, with the specified SMTP host.
 
Method Summary
 void send(EmailMessage message)
          Attempts to deliver the message via the specified SMTP host.
 void setDebug(boolean debug, java.io.PrintStream out)
          Enable or disable the underlying implementation's debug flag, if there is one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SMTPEmailTransport

public SMTPEmailTransport()
                   throws EmailException
Constructs a new SMTPEmailTransport object that will use the local host as its SMTP server.

Throws:
EmailException - unable to initialize

SMTPEmailTransport

public SMTPEmailTransport(java.lang.String smtpHost)
                   throws EmailException
Constructs a new SMTPEmailTransport object, with the specified SMTP host.

Parameters:
smtpHost - The SMTP host to use to send messages
Throws:
EmailException - unable to initialize
See Also:
send(EmailMessage)
Method Detail

setDebug

public void setDebug(boolean debug,
                     java.io.PrintStream out)
Enable or disable the underlying implementation's debug flag, if there is one. Debug messages are to be written to the supplied PrintStream.

Specified by:
setDebug in interface EmailTransport
Parameters:
debug - true to enable debug, false to disable it
out - where to dump debug messages, or null for standard output. Ignored unless debug is true.

send

public void send(EmailMessage message)
          throws EmailException
Attempts to deliver the message via the specified SMTP host.

Specified by:
send in interface EmailTransport
Parameters:
message - the message to send
Throws:
EmailException - Failed to send the message.


Copyright © 2004-2007 Brian M. Clapper. All Rights Reserved.