mail.js

/**
 * The `mail` service facilitates the sending of e-mail messages via SMTP.
 * SMTP settings default to those configured in CompleteFTP, but can be overridden by setting
 * the properties of `mail.smtp` as shown below.
 *
 * **Example:**
 * ```
 * mail.smtp.server = "smtp.gmail.com";
 * mail.smtp.port = 587;
 * mail.smtp.userName = "my.account@gmail.com";
 * mail.smtp.password = "my.password";
 * mail.smtp.enableSSL = true;
 *
 * mail.send("sender@test.com", "recipient@test.com", "Test message", "This is a test");
 * ```
 * The above sends a plain-text message.  Rich-text messages may be sent as follows:
 * ```
 * mail.send("sender@test.com", "recipient@test.com", "Test message", {
 *     textPlain: "This is a test",
 *     textHtml: "No, <b>this</b> is a test"
 * });
 * ```
 * @namespace
 */
mail = {

	/**
	 * SMTP server configuration
	 * 
	 * @type {Object}
	 * @property {String} server Host-name or IP address of SMTP server. 
	 * @property {String} port Port of SMTP server.
	 * @property {String} userName User-name of account on SMTP server.
	 * @property {String} password Password of account on SMTP server.
	 * @property {Boolean} enableSSL Set to true if using SSL. 
	 */
	smtp: {
		server: "",
		port: 0,
		userName: "",
		password: "",
		enableSSL: false
	},

	/**
	 * Sends an e-mail message via SMTP as configured by the `smtp` object of this 
	 * class.  The body of the message may be a simple string (plain-text) or an object
	 * defining a multi-part MIME encoded message (see below).  Attachments from the
	 * CompleteFTP virtual file-system may also be added. 
	 * 
	 * @method
	 * @param {String} from From address
	 * @param {String} to To address
	 * @param {String} [subject] Subject of the message
	 * @param {Object} [body] Body of the message.  This may either be a simple string or an
	 *                        object.  If it's an object then a MIME multi-part message will be
	 *                        generated.  One part will be generated for each property.  The
	 *                        MIME type of the part is determined by the name of the property,
	 *                        e.g. the property "textPlain" becomes the type "text/plain", and
	 *                        "textHtml" becomes "text/html".  The content of a part is the
	 *                        stringified value of the corresponding property value.
	 * @param {String[]} [attachments] Array of strings containing the paths in the virtual file-system
	 *                              of the files to be attached.
	 * @param {Object} [headers] Name-value pairs of header variables.
	 */
	send: function (from, to, subject, body, attachments, headers) { },
};