Guest User

Untitled

a guest
Jan 15th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. const rp = require("request-promise");
  2. const moment = require("moment");
  3.  
  4. const config = require("../../config/smtp");
  5.  
  6. exports.notify = function(project, note) {
  7. var options = {
  8. method: "POST",
  9. uri: config.uri,
  10. headers: {
  11. "content-type": "application/json"
  12. },
  13. body: {
  14. recipients: {
  15. to: [
  16. {
  17. name: "The Recipient",
  18. address: "email@email.com"
  19. }
  20. ]
  21. },
  22. originator: {
  23. from: {
  24. name: "Recipient's Notification System",
  25. address: "notifications@email.com"
  26. },
  27. reply_to: {
  28. name: "Do Not Reply",
  29. address: "donotreply@email.com"
  30. }
  31. },
  32. custom_headers: {},
  33. subject:
  34. "New note on Job " +
  35. project._projectid +
  36. " | " +
  37. project.location.line1,
  38. body: {
  39. parts: [
  40. {
  41. type: "text/html",
  42. charset: "UTF-8",
  43. content:
  44. "The following note was left on Project " +
  45. project._projectid +
  46. ":nn" +
  47. note.content +
  48. "nn" +
  49. "Author: " +
  50. note.meta.author.name +
  51. "at " +
  52. moment(note.meta.created).format("MM/DD/YYYY hh:MMa")
  53. }
  54. ],
  55. attachments: []
  56. }
  57. },
  58. json: true // Automatically stringifies the body to JSON
  59. };
  60. rp(options)
  61. .then(res => {
  62. console.log(res);
  63. })
  64. .catch(err => {
  65. console.error(err);
  66. });
  67. };
Add Comment
Please, Sign In to add comment