Advertisement
Guest User

:)

a guest
Sep 7th, 2018
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. const express = require('express');
  2. const nodemailer = require('nodemailer');
  3. const router = express.Router();
  4. const cron = require('node-cron')
  5.  
  6. cron.schedule('0 0 0 * * *', function(){
  7. console.log('happy birthday ross!');
  8. let transporter = nodemailer.createTransport({
  9. service: 'gmail',
  10. port: 465,
  11. secure: true,
  12. auth: {
  13. user: '***this info is our secret, you can't see it ross***',
  14. pass: '***this info is our secret, you can't see it ross***'
  15. },
  16. // for handling request from local host
  17. tls: {
  18. rejectUnauthorized: false
  19. }
  20. });
  21.  
  22. const mailList = [
  23. 'qualeyro@gmail.com'
  24. ];
  25.  
  26. const output = `<p>Happy Birthday...../p>`;
  27.  
  28. // setup email data with unicode symbols
  29. let mailOptions = {
  30. from: 'God', // sender address
  31. to: mailList, // list of receivers
  32. subject: 'Im watching you', // Subject line
  33. text: 'Happy Birthday.....', // plain text body
  34. html: output // html body
  35. };
  36.  
  37. // send mail with defined transport object
  38. transporter.sendMail(mailOptions, (error, info) => {
  39. if (error) {
  40. return console.log(error);
  41. }
  42. console.log('Message sent: %s', info.messageId);
  43. console.log('info rawL ', info);
  44. console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info));
  45. console.log('email has been sent');
  46. });
  47.  
  48. });
  49.  
  50. module.exports = router;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement