|
WebObjects 5.4.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.webobjects.appserver.WOMailDelivery
public class WOMailDelivery
WOMailDelivery constructs and delivers email messages. It can send both plain-text messages (you supply the string) and rich-text messages (you supply the WOComponent).
WOMailDelivery requires a SMTP server to be set (if no value is provided, the default-and-probably-wrong "smtp
" is used). You can set the SMTP server using a number of methods:
Properties
file: WOSMTPHost=smtp.example.com
-DWOSMTPHost=smtp.example.com
WOApplication.application().setSMTPHost("smtp.example.com");
Usage: WOMailDelivery is a singleton, accessed via its sharedInstance()
method:
WOMailDelivery.sharedInstance().composePlainTextEmail(fromAddress, toAddresses, bccAddresses, subject, body, WOMailDelivery.SEND_NOW);
JavaMail vs. SmtpClient: WOMailDelivery will use JavaMail if it is installed, enabling features such as BCC addressing, MIME-encoded messages, threaded delivery and better SMTP server compatibility (otherwise the older sun.net.smtp.SmtpClient is used). You can install JavaMail by copying
activation.jar
and mail.jar
(installed in /ThirdPartyJars
) into /Library/WebObjects/Extensions
.
Nested Class Summary | |
---|---|
protected static class |
WOMailDelivery.ThreadedTransportSender
Intentionally undocumented. |
Field Summary | |
---|---|
static boolean |
DONT_SEND
Constant for passing as sendNow parameter to composeComponentEmail and
composePlainTextEmail . |
protected Object |
mailSession
Intentionally undocumented. |
static boolean |
SEND_NOW
Constant for passing as sendNow parameter to composeComponentEmail and
composePlainTextEmail . |
Constructor Summary | |
---|---|
protected |
WOMailDelivery()
This protected constructor initializes a newly-instantiated WOMailDelivery object. |
Method Summary | |
---|---|
String |
composeComponentEmail(String aSender,
NSArray toAddresses,
NSArray bccAddresses,
String aSubject,
WOComponent aComponent,
boolean sendNow)
Composes and optionally delivers a rich-text email message. |
String |
composePlainTextEmail(String aSender,
NSArray toAddresses,
NSArray bccAddresses,
String aSubject,
String aMessage,
boolean sendNow)
Composes and optionally delivers a plain-text email message. |
protected boolean |
hasJavaMail()
Intentionally undocumented. |
protected Object |
mailSession()
Intentionally undocumented. |
protected String |
mimeMessageToString(Object smtpMessage)
Intentionally undocumented. |
protected Object |
newMimeMessage(String fromEmailAddress,
NSArray toEmailAddresses,
NSArray bccEmailAddresses,
String subject,
String message,
String contentType,
boolean sendNow)
Intentionally undocumented. |
void |
sendEmail(String mailString)
Sends mailString , with mailString being a String conforming to the SMTP format. |
static WOMailDelivery |
sharedInstance()
Returns the shared instance of WOMailDelivery that all classes should use. |
String |
toString()
Returns a String representation of the WOMailDelivery object containing the receiver's class name and the SMTP host name. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Object mailSession
public static final boolean SEND_NOW
sendNow
parameter to composeComponentEmail
and
composePlainTextEmail
.
public static final boolean DONT_SEND
sendNow
parameter to composeComponentEmail
and
composePlainTextEmail
.
Constructor Detail |
---|
protected WOMailDelivery()
sharedInstance
class method.
WOMailDelivery.sharedInstance()
Method Detail |
---|
public static WOMailDelivery sharedInstance()
public String composePlainTextEmail(String aSender, NSArray toAddresses, NSArray bccAddresses, String aSubject, String aMessage, boolean sendNow)
aSender
- Required String corresponding to the Sender of the mailtoAddresses
- Required NSArray of addresses in the To listbccAddresses
- Optional NSArray of addresses in the Cc list. If JavaMail is not enabled, these addresses are added to toAddresses
since sun.net.smtp.SmtpClient does not support BCC addressing.aSubject
- Required String corresponding to the Subject of the mailaMessage
- Required String message body using ASCII characterssendNow
- boolean flag indicating whether the mail is to be sent immediately
public String composeComponentEmail(String aSender, NSArray toAddresses, NSArray bccAddresses, String aSubject, WOComponent aComponent, boolean sendNow)
The body of the message is the HTML generated when this method invokes generateResponse
on aComponent
. WOMailDelivery uses the WOCGIAdaptorURL
default to complete all URLs in the message to be mailed, so the email's recipient can click on the URLs
to visit them. If sendNow
is true
, the message is sent immediately.
aSender
- Required String corresponding to the Sender of the mailtoAddresses
- Required NSArray of addresses in the To listbccAddresses
- Optional NSArray of addresses in the Cc list. If JavaMail is not enabled, these addresses are added to toAddresses
since sun.net.smtp.SmtpClient does not support BCC addressing.aSubject
- Required String corresponding to the Subject of the mailaComponent
- Required current componentsendNow
- boolean flag indicating whether the mail is to be sent immediately
WOApplication.cgiAdaptorURL()
public void sendEmail(String mailString)
mailString
, with mailString
being a String conforming to the SMTP format. The compose...Email
methods return such Strings. Calling these methods with sendNow
set to false
allows the caller to modify the returned
String before using this method to send it.
mailString
- composed mail message as a String in SMTP format.public String toString()
toString
in class Object
protected Object mailSession()
protected boolean hasJavaMail()
protected Object newMimeMessage(String fromEmailAddress, NSArray toEmailAddresses, NSArray bccEmailAddresses, String subject, String message, String contentType, boolean sendNow)
protected String mimeMessageToString(Object smtpMessage)
|
Last updated June 2008 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |