-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initiall Commit for email automation
- Loading branch information
0 parents
commit 88c22d3
Showing
5 changed files
with
453 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const cron = require('node-cron'); | ||
const nodemailer = require('nodemailer'); | ||
|
||
// Configure your Gmail account | ||
const transporter = nodemailer.createTransport({ | ||
service: 'gmail', | ||
auth: { | ||
user: '[email protected]', | ||
pass: '@2xbet,com_94!', | ||
}, | ||
}); | ||
|
||
// Define the email options | ||
const mailOptions = { | ||
from: '[email protected]', | ||
to: '[email protected]', | ||
subject: 'Scheduled Email', | ||
text: 'This is an automated email sent using Node.js and Gmail.', | ||
}; | ||
|
||
// Schedule the email to be sent every day at 9 AM | ||
cron.schedule('*/1 * * * *', () => { | ||
sendEmail(); | ||
}) | ||
|
||
// { timezone: 'Western Sahara Standard Time' }); // Set your timezone (e.g., 'America/New_York') | ||
|
||
// Function to send the email | ||
function sendEmail() { | ||
transporter.sendMail(mailOptions, (error, info) => { | ||
if (error) { | ||
console.error('Error sending email:', error); | ||
} else { | ||
console.log('Email sent:', info.response); | ||
} | ||
}); | ||
} |
Oops, something went wrong.