All Packages Class Hierarchy This Package Previous Next Index
Class msch.smtp.smtp
java.lang.Object
|
+----msch.smtp.smtp
- public class smtp
- extends Object
This is a simple smtp class which provides all the necessary
functions to send mail from within a JAVA program.
It was inspired by the euqally simple pop3 class from J. Thomas
-
_StatusOK
-
-
debugOn
-
-
Host
-
-
LastCmd
-
-
Port
-
-
replyTo
-
-
Server
-
-
ServerInputStream
-
-
Version
-
-
X_Mailer
-
-
smtp()
-
-
close()
- This method closes the socket
and must be called after mail has
been sent and after the endCommunication command
has been issued.
-
connect()
- Connects to a host and port specified during
initialization of the class.
-
connect(String)
- Makes a connection to the host specified.
-
connect(String, int)
- Makes a connection to the host and port specified.
-
endCommunication()
- Signals to the host that no more mail data
is going to be sent.
-
help()
- Requests a help string from the host.
-
noop()
- Does not do anything but keeps the host "alive"
which will reply with a "250" answer.
-
reset()
- If this command is send before the endCommunication
command, then the mail is not sent and all the buffers
in the host are reset.
-
sendData(String)
- Sends data contained in a string.
-
sendData(String, String)
- Sends data contained in a string.
-
sendFromName(String)
- This is the first command to be sent after the
host has accepted the startCommunication() command.
-
sendToName(String)
- This must be issued right after the sendFromName()
command.
-
setDebugOn(boolean)
- Switches the class into debug mode
-
setReplyTo(String)
- Sets the default ReplyTo field for the mail header
-
setXMailer(String)
- Sets the X-Mailer variable which is send with the
mail header
param mailer = the name of the program using this class lib
-
smtp()
- Constructs the smtp client.
-
smtp(String, int)
- Constructs the smtp client.
-
startCommunication()
- This method sends a "HELO" command to the host,
after which the mail transfer may start.
Version
protected String Version
LastCmd
protected String LastCmd
Host
protected String Host
Port
protected int Port
Server
protected Socket Server
ServerInputStream
protected BufferedReader ServerInputStream
_StatusOK
protected boolean _StatusOK
X_Mailer
protected String X_Mailer
replyTo
protected String replyTo
debugOn
public boolean debugOn
smtp
public smtp()
smtp
public void smtp(String host,
int port)
- Constructs the smtp client.
- Parameters:
- host - = host's IP address
- port - = host's smtp port (usually 25)
smtp
public void smtp()
- Constructs the smtp client. With a port initialized to 25
setXMailer
public void setXMailer(String mailer)
- Sets the X-Mailer variable which is send with the
mail header
param mailer = the name of the program using this class lib
setReplyTo
public void setReplyTo(String replyTo)
- Sets the default ReplyTo field for the mail header
- Parameters:
- replyTo - = reply to address
connect
public smtpStatus connect(String host)
- Makes a connection to the host specified.
- Parameters:
- host - = IP address of the host
connect
public smtpStatus connect(String host,
int port)
- Makes a connection to the host and port specified.
- Parameters:
- host - = IP address of the host
connect
public synchronized smtpStatus connect()
- Connects to a host and port specified during
initialization of the class. This class opens
the communication channel and if the host
accepts the link it will answer with "220".
And appropriate status is returned to indicate
to the calling program what to do next.
close
public synchronized smtpStatus close()
- This method closes the socket
and must be called after mail has
been sent and after the endCommunication command
has been issued.
startCommunication
public synchronized smtpStatus startCommunication()
- This method sends a "HELO" command to the host,
after which the mail transfer may start. If the
host is ready it will send a "25" response
endCommunication
public synchronized smtpStatus endCommunication()
- Signals to the host that no more mail data
is going to be sent. The host should acknowledge
with a "221" command.
sendFromName
public synchronized smtpStatus sendFromName(String from)
- This is the first command to be sent after the
host has accepted the startCommunication() command.
- Parameters:
- from - = the senders (your) address.
sendToName
public synchronized smtpStatus sendToName(String to)
- This must be issued right after the sendFromName()
command. This command may be issued repeatedly for every receiver !
- Parameters:
- to - = the receivers address.
sendData
public synchronized smtpStatus sendData(String data)
- Sends data contained in a string.
The complete message must be contained in
the string ! It is not possible to send line by line !
- Parameters:
- data - = String containing the mail message
sendData
public synchronized smtpStatus sendData(String Subject,
String data)
- Sends data contained in a string. And prefixes a Subject line
to it. The complete message must be contained in
the string ! It is not possible to send line by line !
- Parameters:
- Subject - = String containing the subject line
- data - = String containing the complete mail message
reset
public synchronized smtpStatus reset()
- If this command is send before the endCommunication
command, then the mail is not sent and all the buffers
in the host are reset. This command should always be sent
when you have received a false status from any of the
other mail commands.
noop
public synchronized smtpStatus noop()
- Does not do anything but keeps the host "alive"
which will reply with a "250" answer.
help
public synchronized smtpStatus help()
- Requests a help string from the host.
Note: not all hosts have implemented
this command. Which will result in a "502"
command not implemented.
setDebugOn
public void setDebugOn(boolean OnOff)
- Switches the class into debug mode
- Parameters:
- OnOff - = boolean flag
All Packages Class Hierarchy This Package Previous Next Index