public class SimpleSMTPHeader
extends java.lang.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;
SMTPClient
Modifier and Type | Field and Description |
---|---|
private java.lang.StringBuffer |
__cc |
private java.lang.String |
__from |
private java.lang.StringBuffer |
__headerFields |
private java.lang.String |
__subject |
private java.lang.String |
__to |
private boolean |
hasHeaderDate |
Constructor and Description |
---|
SimpleSMTPHeader(java.lang.String from,
java.lang.String to,
java.lang.String subject)
Creates a new SimpleSMTPHeader instance initialized with the given
from, to, and subject header field values.
|
Modifier and Type | Method and Description |
---|---|
void |
addCC(java.lang.String address)
Add an email address to the CC (carbon copy or courtesy copy) list.
|
void |
addHeaderField(java.lang.String headerField,
java.lang.String value)
Adds an arbitrary header field with the given value to the article
header.
|
java.lang.String |
toString()
Converts the SimpleSMTPHeader to a properly formatted header in
the form of a String, including the blank line used to separate
the header from the article body.
|
private final java.lang.String __subject
private final java.lang.String __from
private final java.lang.String __to
private final java.lang.StringBuffer __headerFields
private boolean hasHeaderDate
private java.lang.StringBuffer __cc
public SimpleSMTPHeader(java.lang.String from, java.lang.String to, java.lang.String subject)
from
- The value of the From:
header field. This
should be the sender's email address.
Must not be null.to
- The value of the To:
header field. This
should be the recipient's email address.
May be nullsubject
- The value of the Subject:
header field.
This should be the subject of the message.
May be nullpublic void addHeaderField(java.lang.String headerField, java.lang.String value)
header.addHeaderField("Organization", "Foobar, Inc.");
headerField
- The header field to add, not including the colon.value
- The value of the added header field.public void addCC(java.lang.String address)
address
- The email address to add to the CC list.public java.lang.String toString()
toString
in class java.lang.Object