2013-12-20 01:49:47 +00:00
|
|
|
/*!
|
2013-07-03 05:37:31 +00:00
|
|
|
* Module Dependencies.
|
|
|
|
*/
|
|
|
|
|
2013-07-16 17:49:25 +00:00
|
|
|
var Model = require('../loopback').Model
|
2013-10-12 02:06:16 +00:00
|
|
|
, loopback = require('../loopback');
|
2013-07-03 05:37:31 +00:00
|
|
|
|
|
|
|
var properties = {
|
|
|
|
to: {type: String, required: true},
|
|
|
|
from: {type: String, required: true},
|
|
|
|
subject: {type: String, required: true},
|
|
|
|
text: {type: String},
|
|
|
|
html: {type: String}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-12-20 01:49:47 +00:00
|
|
|
* The Email Model.
|
|
|
|
*
|
|
|
|
* **Properties**
|
|
|
|
*
|
|
|
|
* - `to` - **{ String }** **required**
|
|
|
|
* - `from` - **{ String }** **required**
|
|
|
|
* - `subject` - **{ String }** **required**
|
|
|
|
* - `text` - **{ String }**
|
|
|
|
* - `html` - **{ String }**
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @inherits {Model}
|
2013-07-03 05:37:31 +00:00
|
|
|
*/
|
|
|
|
|
2013-11-11 21:35:54 +00:00
|
|
|
var Email = module.exports = Model.extend('Email', properties);
|
2013-12-20 01:49:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Send an email with the given `options`.
|
|
|
|
*
|
|
|
|
* Example Options:
|
|
|
|
*
|
|
|
|
* ```json
|
|
|
|
* {
|
|
|
|
* from: "Fred Foo ✔ <foo@blurdybloop.com>", // sender address
|
|
|
|
* to: "bar@blurdybloop.com, baz@blurdybloop.com", // list of receivers
|
|
|
|
* subject: "Hello ✔", // Subject line
|
|
|
|
* text: "Hello world ✔", // plaintext body
|
|
|
|
* html: "<b>Hello world ✔</b>" // html body
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* See https://github.com/andris9/Nodemailer for other supported options.
|
|
|
|
*
|
|
|
|
* @param {Object} options
|
|
|
|
* @param {Function} callback Called after the e-mail is sent or the sending failed
|
|
|
|
*/
|
|
|
|
|
|
|
|
Email.prototype.send = function() {
|
|
|
|
throw new Error('You must connect the Email Model to a Mail connector');
|
|
|
|
}
|