Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const rp = require("request-promise");
- const moment = require("moment");
- const config = require("../../config/smtp");
- exports.notify = function(project, note) {
- var options = {
- method: "POST",
- uri: config.uri,
- headers: {
- "content-type": "application/json"
- },
- body: {
- recipients: {
- to: [
- {
- name: "The Recipient",
- address: "email@email.com"
- }
- ]
- },
- originator: {
- from: {
- name: "Recipient's Notification System",
- address: "notifications@email.com"
- },
- reply_to: {
- name: "Do Not Reply",
- address: "donotreply@email.com"
- }
- },
- custom_headers: {},
- subject:
- "New note on Job " +
- project._projectid +
- " | " +
- project.location.line1,
- body: {
- parts: [
- {
- type: "text/html",
- charset: "UTF-8",
- content:
- "The following note was left on Project " +
- project._projectid +
- ":nn" +
- note.content +
- "nn" +
- "Author: " +
- note.meta.author.name +
- "at " +
- moment(note.meta.created).format("MM/DD/YYYY hh:MMa")
- }
- ],
- attachments: []
- }
- },
- json: true // Automatically stringifies the body to JSON
- };
- rp(options)
- .then(res => {
- console.log(res);
- })
- .catch(err => {
- console.error(err);
- });
- };
Add Comment
Please, Sign In to add comment