Index
Class COM.rajiv.net.SendMail
COM.rajiv.net.SendMail
- public class SendMail
The SendMail class provides a simple mechanism for sending
e-mails using SMTP.
- Version:
- 1.0 1996/Sep/17
- Author:
- Rajiv Pant (Betul) betul@rajiv.com http://rajiv.com
-
SendMail()
-
-
deliver()
- The deliver() method connects to the SMTP server and delivers the message.
-
getSMTPServer()
- The getSMTPServer() method returns the name of the currently
set SMTP Server.
-
setBody(String)
- The setBody (String) method sets the message's body text.
-
setFrom(String)
- The setFrom (String) method sets the "From" address used
in the "MAIL FROM: " part of the SMTP handshake.
-
setHeaders(String)
- The setHeaders (String) method sets the message's headers.
-
setSMTPServer(String)
- The setSMTPServer(String) method is used to set the name of the
SMTP server the deliver method will use to deliver the message.
-
setTo(String)
- The setTo (String) method sets the "To" address used
in the "RCPT TO: " part of the SMTP handshake.
SendMail
public SendMail()
setSMTPServer
public void setSMTPServer(String host)
- The setSMTPServer(String) method is used to set the name of the
SMTP server the deliver method will use to deliver the message.
- Parameters:
- host - The host to use as the SMTP server.
getSMTPServer
public String getSMTPServer()
- The getSMTPServer() method returns the name of the currently
set SMTP Server.
setFrom
public void setFrom(String address)
- The setFrom (String) method sets the "From" address used
in the "MAIL FROM: " part of the SMTP handshake.
- Parameters:
- address - The e-mail address of sender of the message.
setTo
public void setTo(String address)
- The setTo (String) method sets the "To" address used
in the "RCPT TO: " part of the SMTP handshake.
- Parameters:
- address - The e-mail address of the message recipient.
setHeaders
public void setHeaders(String text)
- The setHeaders (String) method sets the message's headers.
Each header is separated by a new line.
The "From: " and a "To: " need to be specified even though
the From and To used in the SMTP handshake are set by the
setFrom (String) and setTo (String) methods.
--- begin example ---
From: Rajiv Betul
To: Bill Gates
Cc: Scott McNealey
Bcc: Cool Person
Subject: Tomorrow's Party
--- end example ---
- Parameters:
- text - The message headers.
setBody
public void setBody(String text)
- The setBody (String) method sets the message's body text.
TO DO: Check the body text to make sure it does not contain
a lone period in a line by itself.
Also fix lines that begin with a "From ".
- Parameters:
- text - The message body.
deliver
public void deliver() throws SendMailCouldNotDeliverException
- The deliver() method connects to the SMTP server and delivers the message.
The String it returns contains any responses it gets from the
SMTP server while trying to deliver the e-mail.
This method does not retry or queue the message for later delivery
if the connection fails.
I may upgrade it later to become more fail-safe.
For more information on SMTP, refer to the following documents:
RFC822 (Message Format)
ftp://ds.internic.net/rfc/rfc822.txt
RFC821 (SMTP Protocol)
ftp://ds.internic.net/rfc/rfc821.txt
RFC1891 - 1894 (ESMTP Extensions)
ftp://ds.internic.net/rfc/rfc1891.txt
- Throws: SendMailCouldNotDeliverException
- when the server could not deliver the message.
Index