|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.mozilla.javascript.ScriptableObject
org.jaggeryjs.modules.email.SenderHostObject
public class SenderHostObject
The sender host object allows users to send out email from their mashups. It helps notify users of certain events and acts as a bridge between mashups and users. Notes: The constructor of the Emal object can be called with or without user credentials. If its called with credentials they are used to authenticate the user. If the function is called without credentials the details are taken from the server.xml found under conf directory where the mashup server is located. So if you wish to keep the credentials in server.xml please update it with the needed usernames and passwords. The section that corresponds to this is as follows.
eg:
function sendEmail(){
var email = new Sender("host", "port", "username", "password");
var file = new File("temp.txt");
email.from = "keith@wso2.com";
email.to = "keith@wso2.com"; // alternatively message.to can be a array of strings. Same goes for cc and bcc
email.cc = "keith@wso2.com";
email.bcc = "keith@wso2.com";
email.subject = "WSO2 Mashup server 1.0 Released";
email.addAttachement(file, "temp.txt"); // Optionally can add attachements, it has a variable number of arguments. each argument can be a File hostObject or a string representing a file.
email.text = "WSO2 Mashup server 1.0 was Released on 28th January 2008";
email.send();
}
| Field Summary |
|---|
| Fields inherited from class org.mozilla.javascript.ScriptableObject |
|---|
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST |
| Fields inherited from interface org.mozilla.javascript.Scriptable |
|---|
NOT_FOUND |
| Constructor Summary | |
|---|---|
SenderHostObject()
|
|
| Method Summary | |
|---|---|
String |
getClassName()
Return the name of the class. |
static org.mozilla.javascript.Scriptable |
jsConstructor(org.mozilla.javascript.Context cx,
Object[] args,
org.mozilla.javascript.Function ctorObj,
boolean inNewExpr)
The Sender Object has three different constructors. |
static void |
jsFunction_addAttachment(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
Object[] arguments,
org.mozilla.javascript.Function funObj)
Add attachments to the mail been sent. |
void |
jsFunction_send()
Send the mail out |
String[] |
jsGet_bcc()
|
String[] |
jsGet_cc()
|
String |
jsGet_from()
|
String |
jsGet_html()
|
String |
jsGet_subject()
|
String |
jsGet_text()
|
String[] |
jsGet_to()
|
void |
jsSet_bcc(Object bccObject)
The bcc address that the mail is sent to |
void |
jsSet_cc(Object ccObject)
The cc address that the mail is sent to |
void |
jsSet_from(String from)
The from address to appear in the sender |
void |
jsSet_html(Object html)
The body of the sender to be sent. |
void |
jsSet_subject(String subject)
The subject of the mail been sent |
void |
jsSet_text(String text)
The body text of the mail been sent |
void |
jsSet_to(Object toObject)
The to address that the mail is sent to |
| Methods inherited from class org.mozilla.javascript.ScriptableObject |
|---|
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, equivalentValues, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasInstance, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype, size |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SenderHostObject()
| Method Detail |
|---|
public String getClassName()
getClassName in interface org.mozilla.javascript.ScriptablegetClassName in class org.mozilla.javascript.ScriptableObject
public static org.mozilla.javascript.Scriptable jsConstructor(org.mozilla.javascript.Context cx,
Object[] args,
org.mozilla.javascript.Function ctorObj,
boolean inNewExpr)
throws org.jaggeryjs.scriptengine.exceptions.ScriptException
The Sender Object has three different constructors. Choose one depending on your configuration and your needs.
1. The first constructor takes no parameters and uses configuration information specified in the server.xml. Using a configuration such as this is useful if you want to use a default email account to send out mail from your mashups. It also reduces the hassle of having to key in the configuration details each time you need a new email object. var email = new Sender(); 2. The second constructor, unlike the first, requires the user to provide the configuration details each time he creates a new email object. The benefit is that no server configuration is needed and you can use diffent accounts when ever you need. The configuration details should be given as follows: var email = new Sender("smtp.gmail.com", "25", "username@gmail.com", "password"); // host, port, username, password 3. The third is a slight variant of the second. It does not require a port to be specified: var email = new Sender("smtp.gmail.com", "username@gmail.com", "password"); // host, username, password
org.jaggeryjs.scriptengine.exceptions.ScriptException
public void jsSet_from(String from)
throws org.jaggeryjs.scriptengine.exceptions.ScriptException
The from address to appear in the sender
sender.from = "keith@wso2.com";
org.jaggeryjs.scriptengine.exceptions.ScriptException
public String jsGet_from()
throws javax.mail.MessagingException
javax.mail.MessagingException
public String[] jsGet_to()
throws org.jaggeryjs.scriptengine.exceptions.ScriptException
org.jaggeryjs.scriptengine.exceptions.ScriptException
public void jsSet_to(Object toObject)
throws org.jaggeryjs.scriptengine.exceptions.ScriptException
The to address that the mail is sent to
sender.to = "keith@wso2.com"; OR var to = new Array(); to[0] = "jonathan@wso2.com"; to[1] = "keith@wso2.com"; sender.to = to;
org.jaggeryjs.scriptengine.exceptions.ScriptException
public String[] jsGet_cc()
throws org.jaggeryjs.scriptengine.exceptions.ScriptException
org.jaggeryjs.scriptengine.exceptions.ScriptException
public void jsSet_cc(Object ccObject)
throws org.jaggeryjs.scriptengine.exceptions.ScriptException
The cc address that the mail is sent to
sender.cc = "keith@wso2.com"; OR var cc = new Array(); cc[0] = "jonathan@wso2.com"; cc[1] = "keith@wso2.com"; sender.cc = cc;
org.jaggeryjs.scriptengine.exceptions.ScriptException
public String[] jsGet_bcc()
throws org.jaggeryjs.scriptengine.exceptions.ScriptException
org.jaggeryjs.scriptengine.exceptions.ScriptException
public void jsSet_bcc(Object bccObject)
throws org.jaggeryjs.scriptengine.exceptions.ScriptException
The bcc address that the mail is sent to
sender.bcc = "keith@wso2.com"; OR var bcc = new Array(); bcc[0] = "jonathan@wso2.com"; bcc[1] = "keith@wso2.com"; sender.bcc = bcc;
org.jaggeryjs.scriptengine.exceptions.ScriptException
public void jsSet_subject(String subject)
throws org.jaggeryjs.scriptengine.exceptions.ScriptException
The subject of the mail been sent
sender.subject = "WSO2 Mashup server 1.0 Released";
org.jaggeryjs.scriptengine.exceptions.ScriptException
public String jsGet_subject()
throws org.jaggeryjs.scriptengine.exceptions.ScriptException
org.jaggeryjs.scriptengine.exceptions.ScriptException
public void jsSet_text(String text)
throws org.jaggeryjs.scriptengine.exceptions.ScriptException
The body text of the mail been sent
sender.text = "WSO2 Mashup server 1.0 was Released on 28th January 2008";
org.jaggeryjs.scriptengine.exceptions.ScriptExceptionpublic String jsGet_text()
public void jsSet_html(Object html)
throws org.jaggeryjs.scriptengine.exceptions.ScriptException
The body of the sender to be sent. This function can be used to send HTML mail.
sender.html = "WSO2 Mashup server 1.0 was Released on 28th January 2008
"; // Setthing the HTML content as a String OR sender.html =WSO2 Mashup server 1.0 was Released on 28th January 2008
; // Setting the HTML content as an XML object
org.jaggeryjs.scriptengine.exceptions.ScriptExceptionpublic String jsGet_html()
public void jsFunction_send()
throws org.jaggeryjs.scriptengine.exceptions.ScriptException
Send the mail out
sender.send()
org.jaggeryjs.scriptengine.exceptions.ScriptException
public static void jsFunction_addAttachment(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
Object[] arguments,
org.mozilla.javascript.Function funObj)
throws org.jaggeryjs.scriptengine.exceptions.ScriptException
Add attachments to the mail been sent. This function has a variable number of arguments, each argument can be a File hostObject or a string representing a file.
var file = new File("temp.txt"); // A file exists at temp.txt
sender.addAttachement(file, "temp.txt");
org.jaggeryjs.scriptengine.exceptions.ScriptException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||