Guest User

Untitled

a guest
Feb 28th, 2018
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. 'use strict';
  2. /* jshint node: true */
  3.  
  4. const nodemailer = require('nodemailer');
  5. const moment = require('moment');
  6.  
  7. function setSubject() {
  8. let dayName = moment().format('dddd');
  9. let dayNumber = moment().format('D');
  10. let monthName = moment().format('MMMM');
  11. let yearNumber = moment().format('YYYY');
  12. const subject = `Daily Status Report for ${dayName}, ${dayNumber} ${monthName}, ${yearNumber}`;
  13. return subject;
  14. }
  15.  
  16. function setBody() {
  17. let doneMessage = `<p style="font-weight:bold">Work done today:</p>`;
  18. let impediments = `<p style="font-weight:bold">There are no impediments to report.</p>
  19. <p style="font-weight:bold">There are no upcoming holidays or planned time off.</p>`;
  20. let doneTasks = `- Flip the order on "What is SMOON" and remove the title from the page<br>
  21. - Fix styling on "What is SMOON" and "Specs" pages<br>
  22. - Fix media queries nn "What is SMOON" and "Specs" pages<br>
  23. - Fix gallery resizing<br>
  24. - Remove "What is SMOON" link from the navigation, only use this page as a landing page<br>`;
  25. return (`
  26. ${doneMessage}
  27.  
  28. ${doneTasks}
  29.  
  30. ${impediments}
  31. `
  32. );
  33. }
  34. let transporter = nodemailer.createTransport({
  35. host: 'smtp.gmail.com',
  36. port: 587,
  37. secure: false,
  38. requireTLS: true,
  39. auth: {
  40. user: '',
  41. pass: ''
  42. }
  43. });
  44.  
  45. const mailOptions = {
  46. from: 'alejandromatagui97@gmail.com', // sender address
  47. to: 'alejandromatagui97@gmail.com', // list of receivers
  48. subject: setSubject(), // Subject line
  49. html: setBody() // plain text body
  50. };
  51.  
  52. transporter.sendMail(mailOptions, (err, info) => {
  53. if (err) {
  54. console.log(err);
  55. }
  56. else {
  57. console.log(info);
  58. }
  59. });
Add Comment
Please, Sign In to add comment