Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const nodemailer = require('nodemailer');
- const router = express.Router();
- const cron = require('node-cron')
- cron.schedule('0 0 0 * * *', function(){
- console.log('happy birthday ross!');
- let transporter = nodemailer.createTransport({
- service: 'gmail',
- port: 465,
- secure: true,
- auth: {
- user: '***this info is our secret, you can't see it ross***',
- pass: '***this info is our secret, you can't see it ross***'
- },
- // for handling request from local host
- tls: {
- rejectUnauthorized: false
- }
- });
- const mailList = [
- 'qualeyro@gmail.com'
- ];
- const output = `<p>Happy Birthday...../p>`;
- // setup email data with unicode symbols
- let mailOptions = {
- from: 'God', // sender address
- to: mailList, // list of receivers
- subject: 'Im watching you', // Subject line
- text: 'Happy Birthday.....', // plain text body
- html: output // html body
- };
- // send mail with defined transport object
- transporter.sendMail(mailOptions, (error, info) => {
- if (error) {
- return console.log(error);
- }
- console.log('Message sent: %s', info.messageId);
- console.log('info rawL ', info);
- console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info));
- console.log('email has been sent');
- });
- });
- module.exports = router;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement