|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--iaik.utils.SmtpMailer
This class implements a simple SMTP mailing tool. It can be used to send simple EMails over a SMTP mailserver. For further details check out RFC822 (STANDARD FOR THE FORMAT OF ARPA INTERNET TEXT MESSAGES) and RFC821 (SIMPLE MAIL TRANSFER PROTOCOL)
| Constructor Summary | |
SmtpMailer()
Creates a new simple SmtpMailer. |
|
SmtpMailer(java.lang.String host)
Creates a new simple SmtpMailer from a host name. |
|
| Method Summary | |
void |
addAdditionalField(java.lang.String line)
Sets any additional field according to RFC822. |
void |
addBcc(java.lang.String realName,
java.lang.String emailAddress)
Sets the Bcc field. |
void |
addCc(java.lang.String realName,
java.lang.String emailAddress)
Sets the Cc field. |
void |
addText(java.lang.String text)
Adds text to message body of this EMail. |
void |
addTo(java.lang.String realName,
java.lang.String emailAddress)
Sets the To field. |
protected boolean |
checkResponse(int expected)
Checks the response from the smtpd. |
protected boolean |
send(java.lang.String message,
java.io.PrintWriter writer,
int expected)
Prints a string using the specified PrintWriter. |
protected boolean |
sendCommands(java.io.PrintWriter writer)
Sends the SMTP commands to the smtpd. |
boolean |
sendMail()
Send the mail that was just created. |
void |
setDebug(boolean on)
Switches debugging output on or off. |
void |
setFrom(java.lang.String realName,
java.lang.String emailAddress)
Sets the From field. |
void |
setReplyTo(java.lang.String realName,
java.lang.String emailAddress)
Sets the Reply-To field. |
void |
setSubject(java.lang.String subject)
Sets the Subject. |
void |
setText(java.lang.String text)
Sets the message body of this EMail. |
void |
setVerify(boolean on)
If verify is switched on (default) SmtpMailer checks every response code from smtpd and compares it to the expected value. |
java.lang.String |
toString()
Returns a string representation of this SmtpMailer. |
protected void |
writeBody(java.io.PrintWriter writer)
Uses this PrintWriter to print the message body. |
protected void |
writeHeaders(java.io.PrintWriter writer)
Uses this PrintWriter to print the headers. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
| Constructor Detail |
public SmtpMailer(java.lang.String host)
host - the host with the SMTP demonpublic SmtpMailer()
| Method Detail |
public void setFrom(java.lang.String realName,
java.lang.String emailAddress)
realName - the real name of the senderemailAddress - the email address of the sender
public void setReplyTo(java.lang.String realName,
java.lang.String emailAddress)
realName - the real name of one receiveremailAddress - the email address of one receiverpublic void setVerify(boolean on)
on - true to switch verification onpublic void setDebug(boolean on)
on - true switches debugging on
public void addTo(java.lang.String realName,
java.lang.String emailAddress)
realName - the real name of one receiveremailAddress - the email address of one receiver
public void addCc(java.lang.String realName,
java.lang.String emailAddress)
realName - the real name of one receiveremailAddress - the email address of one receiver
public void addBcc(java.lang.String realName,
java.lang.String emailAddress)
realName - the real name of one receiveremailAddress - the email address of one receiverpublic void addAdditionalField(java.lang.String line)
line - a complete linepublic void setSubject(java.lang.String subject)
subject - the subjectpublic void setText(java.lang.String text)
text - the text to be appendedpublic void addText(java.lang.String text)
text - the text to be appended
protected boolean checkResponse(int expected)
throws SmtpException
expected - the expected response code
protected boolean send(java.lang.String message,
java.io.PrintWriter writer,
int expected)
throws SmtpException
message - the string to printwriter - the PrintWriter to use
protected boolean sendCommands(java.io.PrintWriter writer)
throws SmtpException
writer - the PrintWriter to useprotected void writeHeaders(java.io.PrintWriter writer)
writer - the PrintWriter for printing the headersprotected void writeBody(java.io.PrintWriter writer)
writer - the PrintWriter for printing the message body
public boolean sendMail()
throws SmtpException
public java.lang.String toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||