org.apache.commons.net.smtp
public class SimpleSMTPHeader extends Object
The main purpose of the class is to faciliatate the mail sending process, by relieving the programmer from having to explicitly format a simple message header. For example:
writer = client.sendMessageData();
if(writer == null) // failure
return false;
header =
new SimpleSMTPHeader("foobar@foo.com", "foo@bar.com" "Just testing");
header.addCC("bar@foo.com");
header.addHeaderField("Organization", "Foobar, Inc.");
writer.write(header.toString());
writer.write("This is just a test");
writer.close();
if(!client.completePendingCommand()) // failure
return false;
| Constructor Summary | |
|---|---|
| SimpleSMTPHeader(String from, String to, String subject)
Creates a new SimpleSMTPHeader instance initialized with the given
from, to, and subject header field values.
| |
| Method Summary | |
|---|---|
| void | addCC(String address)
Add an email address to the CC (carbon copy or courtesy copy) list.
|
| void | addHeaderField(String headerField, String value)
Adds an arbitrary header field with the given value to the article
header. |
Parameters: from The value of the From: header field. This
should be the sender's email address. to The value of the To: header field. This
should be the recipient's email address. subject The value of the Subject: header field.
This should be the subject of the message.
Parameters: address The email address to add to the CC list.
header.addHeaderField("Organization", "Foobar, Inc.");
Parameters: headerField The header field to add, not including the colon. value The value of the added header field.