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.
EmailMessage
Constructor and Description |
---|
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.
|
SMTPEmailTransport(java.lang.String smtpHost,
java.lang.String thisHost)
Constructs a new SMTPEmailTransport object, with the specified
SMTP host.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public SMTPEmailTransport() throws EmailException
EmailException
- unable to initializepublic SMTPEmailTransport(java.lang.String smtpHost) throws EmailException
smtpHost
- The SMTP host to use to send messagesEmailException
- unable to initializesend(EmailMessage)
public SMTPEmailTransport(java.lang.String smtpHost, java.lang.String thisHost) throws EmailException
smtpHost
- The SMTP host to use to send messagesthisHost
- The name to use for this host. If null, then
InetAddress.getLocalHost().getHostName() is
used.EmailException
- unable to initializesend(EmailMessage)
public void setDebug(boolean debug, java.io.PrintStream out)
setDebug
in interface EmailTransport
debug
- true to enable debug, false to
disable itout
- where to dump debug messages, or null for standard
output. Ignored unless debug is true.public void send(EmailMessage message) throws EmailException
send
in interface EmailTransport
message
- the message to sendEmailException
- Failed to send the message.