Blame view

node_modules/loopback/common/models/email.js 1.79 KB
f7563de62   Palak Handa   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
  // Copyright IBM Corp. 2014,2016. All Rights Reserved.
  // Node module: loopback
  // This file is licensed under the MIT License.
  // License text available at https://opensource.org/licenses/MIT
  
  /**
   * Email model.  Extends LoopBack base [Model](#model-new-model).
   * @property {String} to Email addressee.  Required.
   * @property {String} from Email sender address.  Required.
   * @property {String} subject Email subject string.  Required.
   * @property {String} text Text body of email.
   * @property {String} html HTML body of email.
   *
   * @class Email
   * @inherits {Model}
   */
  
  var g = require('strong-globalize')();
  
  module.exports = function(Email) {
  
    /**
     * Send an email with the given `options`.
     *
     * Example Options:
     *
     * ```js
     * {
     *   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.
     *
     * @options {Object} options See below
     * @prop {String} from Senders's email address
     * @prop {String} to List of one or more recipient email addresses (comma-delimited)
     * @prop {String} subject Subject line
     * @prop {String} text Body text
     * @prop {String} html Body HTML (optional)
     * @param {Function} callback Called after the e-mail is sent or the sending failed
     */
  
    Email.send = function() {
      throw new Error(g.f('You must connect the {{Email}} Model to a {{Mail}} connector'));
    };
  
    /**
     * A shortcut for Email.send(this).
     */
    Email.prototype.send = function() {
      throw new Error(g.f('You must connect the {{Email}} Model to a {{Mail}} connector'));
    };
  };