|
|||||||||
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(String host)
Creates a new simple SmtpMailer from a host name. |
Method Summary | |
void |
addAdditionalField(String line)
Sets any additional field according to RFC822. |
void |
addBcc(String realName,
String emailAddress)
Sets the Bcc field. |
void |
addCc(String realName,
String emailAddress)
Sets the Cc field. |
void |
addText(String text)
Adds text to message body of this EMail. |
void |
addTo(String realName,
String emailAddress)
Sets the To field. |
protected boolean |
checkResponse(int expected)
Checks the response from the smtpd. |
protected boolean |
send(String message,
PrintWriter writer,
int expected)
Prints a string using the specified PrintWriter. |
protected boolean |
sendCommands(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(String realName,
String emailAddress)
Sets the From field. |
void |
setReplyTo(String realName,
String emailAddress)
Sets the Reply-To field. |
void |
setSubject(String subject)
Sets the Subject. |
void |
setText(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. |
String |
toString()
Returns a string representation of this SmtpMailer. |
protected void |
writeBody(PrintWriter writer)
Uses this PrintWriter to print the message body. |
protected void |
writeHeaders(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(String host)
host
- the host with the SMTP demonpublic SmtpMailer()
Method Detail |
public void setFrom(String realName, String emailAddress)
realName
- the real name of the senderemailAddress
- the email address of the senderpublic void setReplyTo(String realName, 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 onpublic void addTo(String realName, String emailAddress)
realName
- the real name of one receiveremailAddress
- the email address of one receiverpublic void addCc(String realName, String emailAddress)
realName
- the real name of one receiveremailAddress
- the email address of one receiverpublic void addBcc(String realName, String emailAddress)
realName
- the real name of one receiveremailAddress
- the email address of one receiverpublic void addAdditionalField(String line)
line
- a complete linepublic void setSubject(String subject)
subject
- the subjectpublic void setText(String text)
text
- the text to be appendedpublic void addText(String text)
text
- the text to be appendedprotected boolean checkResponse(int expected) throws SmtpException
expected
- the expected response codeSmtpException
- if there was an error while reading the responseprotected boolean send(String message, PrintWriter writer, int expected) throws SmtpException
message
- the string to printwriter
- the PrintWriter to useSmtpException
- if there was an error while sending this stringprotected boolean sendCommands(PrintWriter writer) throws SmtpException
writer
- the PrintWriter to useSmtpException
- if there was an error while sending the commandsprotected void writeHeaders(PrintWriter writer)
writer
- the PrintWriter for printing the headersprotected void writeBody(PrintWriter writer)
writer
- the PrintWriter for printing the message bodypublic boolean sendMail() throws SmtpException
SmtpException
- if there is a problem while sending the EMailpublic String toString()
toString
in class Object
|
This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |