Class Index | File Index

Classes


Class Mail

This class represents an interface to the program 'mail'. To send a mail, create an instance and fill the properties (see reference) with proper data.
Defined in: Mail.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Mail()
Field Summary
Field Attributes Field Name and Description
 
Attachments [optional].
 
bcc
Blind carbon copy [optional].
 
cc
Carbon copy [optional].
 
Recipient(s) of the mail.
<constant>  
Subject of the mail
 
Message body.
Method Summary
Method Attributes Method Name and Description
 
send(block)
Send the message.
Class Detail
Mail()

Author: Thomas Bretz.
    var mail = new Mail("This is the subject");

    // At least one recipient is mandatory
    mail.recipients.push("max.mustermann@musterstadt.com");
    // To add several recipients
    mail.recipients.push("max.mustermann@musterstadt.com", "erika.mustermann@musterstadt.com");

    // similar to the property recipient you can use the properties 'cc' and 'bcc'

    // If you want to add attachments [optional]
    mail.attachments.push("logfile.txt");
    // or for several attachments
    mail.attachments.push("logfile1.txt", "logfile2.txt");

    // The text of the message is set in the property text...
    // ...either as single string
    mail.text.push("This is line1\nThis is line2");
    mail.text.push("This is line1");
    mail.text.push("This is line2");

    // Send the message
    mail.send();
Field Detail
{Array[String]} attachments
Attachments [optional]. File to be attached to the mail. All entries in the array which are not a string are silently ignored.

{Array[String]} bcc
Blind carbon copy [optional]. Adresses who should receive a copy of the mail. All entries in the array which are not a string are silently ignored.

{Array[String]} cc
Carbon copy [optional]. Adresses who should receive a copy of the mail. All entries in the array which are not a string are silently ignored.

{Array[String]} recipients
Recipient(s) of the mail. One recipient is mandatory.

<constant> {String} subject
Subject of the mail

{Array[String]} text
Message body. At least one line in the message is mandatory. Undefined or null entries in the array are silently ignored.
Method Detail
{Integer} send(block)
Send the message. This calles the 'mailx' program. For further details, e.g. on the return value, see the corresponding man page.
Parameters:
{Boolean} block Optional, Default: true
This parameter specifies whether the pipe should be closed, which means that a blocking wait is performed until the 'mail' program returns, or the pipe will be closed automatically in the background when the 'mail' program has finished. Note, that if the calling program terminates, maybe this call will never succeed.
Throws:
An exception is thrown if any validity check for the properties or the arguments fail.
Returns:
{Integer} The return code of the 'mail' program is returned (0 usually means success), undefined if block was set to false.

Documentation generated by JsDoc Toolkit 2.4.0 on Sun Sep 18 2016 20:50:08 GMT+0100 (WEST)