Skip to content

Commit

Permalink
Initiall Commit for email automation
Browse files Browse the repository at this point in the history
  • Loading branch information
Qwabs committed Dec 5, 2023
0 parents commit 88c22d3
Show file tree
Hide file tree
Showing 5 changed files with 453 additions and 0 deletions.
Empty file added .env
Empty file.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
37 changes: 37 additions & 0 deletions emailAutomation.js
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);
}
});
}
Loading

0 comments on commit 88c22d3

Please sign in to comment.