|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object uk.org.iscream.cms.util.Smtp
The Simple Mail Transfer Protocol class. This class was inspired by the GJT.
Field Summary | |
private String |
_name
This is the friendly identifier of the component this class is running in. |
private Socket |
_socket
A reference to the Socket connected to the server |
private BufferedReader |
_socketIn
A reference to the Reader connected to the server |
private PrintWriter |
_socketOut
A reference to the Writer connected to the server |
static String |
REVISION
The current CVS revision of this class |
Constructor Summary | |
Smtp(String server)
Connects to the specified SMTP server, on the default (and standard) port 25. |
|
Smtp(String server,
int port)
Connects to the specified SMTP server on a given port |
Method Summary | |
void |
close()
Closes down the connection to the server |
PrintWriter |
getOutputStream()
Gets the PrintWriter allowing data to be sent directly to the SMTP server |
private void |
init()
Check the server sends a 220 message, and then send our HELO. |
void |
sendCommand(String cmd,
int reply)
Sends a command to the server |
void |
sendMessage()
Completes and sends the current message |
void |
setSender(String sender)
Specify who the message is from |
void |
setTo(String to)
Specify who the message is to be sent to |
String |
toString()
Overrides the Object.toString()
method to provide clean logging (every class should have this). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final String REVISION
private String _name
private BufferedReader _socketIn
private PrintWriter _socketOut
private Socket _socket
Constructor Detail |
public Smtp(String server) throws IOException
server
- The SMTP server to use
IOException
- if the connection to the server failspublic Smtp(String server, int port) throws IOException
server
- The SMTP server to useport
- The SMTP server port
IOException
- if the connection to the server failsMethod Detail |
public void close() throws IOException
IOException
- if the command failspublic void setSender(String sender) throws IOException
sender
- the e-mail address of the sender
IOException
- if the command failspublic void setTo(String to) throws IOException
to
- the e-mail address of the receiver
IOException
- if the command failspublic PrintWriter getOutputStream() throws IOException
IOException
- if the command failspublic void sendMessage() throws IOException
IOException
- if the command failspublic void sendCommand(String cmd, int reply) throws IOException
cmd
- The command to sendreply
- The expected reply-code
IOException
- if the incorrect response code is receivedpublic String toString()
Object.toString()
method to provide clean logging (every class should have this).
This uses the uk.org.iscream.cms.server.util.FormatName class
to format the toString()
private void init() throws IOException
IOException
- if something goes wrong
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |