|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--Qsmtp
SMTP mailer class, used to send email messages (with optional HTML MIME attachments) through direct TCP/IP communication with Internet SMTP mail servers.
The Qsmtp constructors take an address for a SMTP mail server, and all messages subsequently sent out by the Qstmp object are handled by that SMTP server.
Once created, a Qsmtp object can be used to send any number of messages
through that mail server. Each call to
sendmsg or
sendHTMLmsg opens a
separate SMTP connection to the designated mail server and transmits a
single message.
Because this class opens a socket to a potentially remote TCP/IP server, this class may not function properly when used within an applet.
| Field Summary | |
private java.net.InetAddress |
address
|
private java.lang.Thread |
backgroundThread
|
(package private) static boolean |
debug
|
(package private) static int |
DEFAULT_PORT
|
(package private) static java.lang.String |
EOL
|
private java.lang.String |
hostid
|
private int |
port
|
private java.util.Vector |
queuedMessages
|
private boolean |
threaded
|
| Constructor Summary | |
Qsmtp(java.net.InetAddress address)
|
|
Qsmtp(java.net.InetAddress address,
int port)
|
|
Qsmtp(java.lang.String hostid)
|
|
Qsmtp(java.lang.String hostid,
int port)
|
|
| Method Summary | |
private void |
dispatchMessage(messageObject msgObj)
This method handles the actual mail-out |
static java.lang.String |
formatDate(java.util.Date date)
This method returns a properly mail-formatted date string. |
void |
goThreaded()
After this method is called, all further sendMsg() calls will not directly send mail themselves, but will rather queue the mail for sending by a back-ground thread. |
void |
run()
Main worker routine for the background thread which handles mail-outs. |
void |
sendHTMLmsg(java.lang.String from_address,
java.util.Vector to_addresses,
java.lang.String subject,
java.lang.String htmlBody,
java.lang.String htmlFilename,
java.lang.String textBody)
Sends a message with a MIME-attached HTML message |
void |
sendmsg(java.lang.String from_address,
java.util.Vector to_addresses,
java.lang.String subject,
java.lang.String message)
Sends a plain ASCII mail message |
void |
sendmsg(java.lang.String from_address,
java.util.Vector to_addresses,
java.lang.String subject,
java.lang.String message,
java.util.Vector extraHeaders)
Sends a mail message with some custom-specified envelope headers. |
void |
stopThreaded()
Calling this method turns off the background thread and returns Qsmtp to normal blocking operation. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
static final boolean debug
static final int DEFAULT_PORT
static final java.lang.String EOL
private java.lang.String hostid
private java.net.InetAddress address
private int port
private java.util.Vector queuedMessages
private boolean threaded
private java.lang.Thread backgroundThread
| Constructor Detail |
public Qsmtp(java.lang.String hostid)
public Qsmtp(java.lang.String hostid,
int port)
public Qsmtp(java.net.InetAddress address)
public Qsmtp(java.net.InetAddress address,
int port)
| Method Detail |
public void goThreaded()
After this method is called, all further sendMsg() calls will not directly send mail themselves, but will rather queue the mail for sending by a back-ground thread.
One result of this is that after this is called, the sendMsg() methods will never throw Protcol or IO Exceptions, and no success/failure results will be returned.
If this method is called while an previous background thread that was ordered to stop by stopThreaded() is still shutting down, this method will block until the old background thread dies and the new background thread can be established.
public void stopThreaded()
Calling this method turns off the background thread and returns Qsmtp to normal blocking operation.
public void sendmsg(java.lang.String from_address,
java.util.Vector to_addresses,
java.lang.String subject,
java.lang.String message)
throws java.io.IOException
Sends a plain ASCII mail message
from_address - Who is sending this message?to_addresses - Vector of string addresses to send this message tosubject - Subject for this messagemessage - The text for the mail messagejava.io.IOException -
public void sendHTMLmsg(java.lang.String from_address,
java.util.Vector to_addresses,
java.lang.String subject,
java.lang.String htmlBody,
java.lang.String htmlFilename,
java.lang.String textBody)
throws java.io.IOException
Sends a message with a MIME-attached HTML message
In a perfect world, we'd do a generic MIME-capable mail system here, but as it is, we only support HTML.
from_address - Who is sending this message?to_addresses - Vector of string addresses to send this message tosubject - Subject for this messagehtmlBody - A string containing the HTML document to be senthtmlFilename - The name to label the HTML document with, will
show up in mail clientstextBody - The text for the non-HTML part of the mail messagejava.io.IOException -
public void sendmsg(java.lang.String from_address,
java.util.Vector to_addresses,
java.lang.String subject,
java.lang.String message,
java.util.Vector extraHeaders)
throws java.io.IOException
Sends a mail message with some custom-specified envelope headers. Used internally by the other Qsmtp sendmsg and sendHTMLmsg methods.
from_address - Who is sending this message?to_addresses - Vector of string addresses to send this message tosubject - Subject for this messagemessage - The text for the mail messageextraHeaders - Vector of string headers to include in the message's
envelopejava.io.IOException - public void run()
Main worker routine for the background thread which handles mail-outs.
run in interface java.lang.Runnable
private void dispatchMessage(messageObject msgObj)
throws java.io.IOException
This method handles the actual mail-out
java.io.IOException - public static java.lang.String formatDate(java.util.Date date)
This method returns a properly mail-formatted date string.
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||