WebObjects 5.2.3

com.webobjects.appserver
Class WOMailDelivery

java.lang.Object
  extended bycom.webobjects.appserver.WOMailDelivery

public class WOMailDelivery
extends Object

WOMailDelivery constructs an email message from a file and uses Sun's sun.net.smtp package to send it. WOMailDelivery requires an SMTP server to be set. If no value is provided, the default "smtp" is used. Note that this default value can be changed by WOApplication as a command-line argument, or by using the mechanisms supplied by NSProperties.

There is only one instance of WOMailDelivery, which you access with the sharedInstance static method. You cannot create one of your own.

See Also:
NSProperties

Constructor Summary
protected WOMailDelivery()
          This protected constructor initializes a newly-instantiated WOMailDelivery object.
 
Method Summary
 String composeComponentEmail(String aSender, NSArray somePeople, NSArray otherPeople, String aSubject, WOComponent aComponent, boolean sendNow)
          Composes an email message to somePeople with From, Cc, and Subject lines, setting the content type of the email as Content-type: text/html.
 String composePlainTextEmail(String aSender, NSArray somePeople, NSArray otherPeople, String aSubject, String aMessage, boolean sendNow)
          Composes an email message to somePeople with From, Cc, and Subject lines.
 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
 

Constructor Detail

WOMailDelivery

protected WOMailDelivery()
This protected constructor initializes a newly-instantiated WOMailDelivery object. WebObjects applications shouldn't allocate WOMailDelivery objects, but instead should make use of the shared instance provided by WOMailDelivery's sharedInstance class method.

See Also:
sharedInstance()
Method Detail

composeComponentEmail

public String composeComponentEmail(String aSender,
                                    NSArray somePeople,
                                    NSArray otherPeople,
                                    String aSubject,
                                    WOComponent aComponent,
                                    boolean sendNow)
Composes an email message to somePeople with From, Cc, and Subject lines, setting the content type of the email as Content-type: text/html.

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.

Because sun.net.smtp does not support Cc headers, addresses in the otherPeople NSArray are added to the To recipients. The Cc header is added anyway for the mail recipient's information.

Parameters:
aSender - String corresponding to the Sender of the mail
somePeople - NSArray of addresses in the To list
otherPeople - NSArray of addresses in the Cc list
aSubject - String corresponding to the Subject of the mail
aComponent - the current component
sendNow - boolean flag indicating whether the mail to be sent immediately
Returns:
the composed mail message as a String
See Also:
WOApplication.cgiAdaptorURL()

composePlainTextEmail

public String composePlainTextEmail(String aSender,
                                    NSArray somePeople,
                                    NSArray otherPeople,
                                    String aSubject,
                                    String aMessage,
                                    boolean sendNow)
Composes an email message to somePeople with From, Cc, and Subject lines. If sendNow is true, the message is sent immediately.

Because sun.net.smtp does not support Cc headers, addresses in the otherPeople NSArray are added to the To recipients. The Cc header is added anyway for the mail recipient's information.

Parameters:
aSender - String corresponding to the Sender of the mail
somePeople - NSArray of addresses in the To list
otherPeople - NSArray of addresses in the Cc list
aSubject - String corresponding to the Subject of the mail
aMessage - String message body using ASCII characters
sendNow - boolean flag indicating whether the mail is to be sent immediately
Returns:
the composed ASCII mail message as a String

sendEmail

public void sendEmail(String mailString)
Sends 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.

Parameters:
mailString - composed mail message as a String in SMTP format.

sharedInstance

public static WOMailDelivery sharedInstance()
Returns the shared instance of WOMailDelivery that all classes should use. Use this instead of creating another instance.

Returns:
the current application's WOMailDelivery singleton

toString

public String toString()
Returns a String representation of the WOMailDelivery object containing the receiver's class name and the SMTP host name.

Returns:
a String representation of the WOMailDelivery object

Last updated Thu Oct 21 15:04:16 PDT 2004.

Copyright © 2004 Apple Computer, Inc.