mail-simplifier
v1.0.1
Published
simple mail sender
Downloads
157
Readme
mail-simplifier
const Mailsender = require('mail-simplifier');
// Create a new Mailsender instance
const mailSender = new Mailsender({
smtpHost: 'smtp.example.com',
smtpPort: 587,
secure: "true", // true or false in string
smtpUsername: 'your_smtp_username',
smtpPassword: 'your_smtp_password',
emailFromName: 'Your Name',
emailFromAddress: '[email protected]',
});
// Prepare the email data
const emailData = {
subject: 'Welcome to Our Service',
toName: 'Jane Doe',
toEmail: '[email protected]',
paths: './verify.ejs',
params: {
username: 'Ramesh',
otp: '123456'
}
};
// params is object what ever data is send to ejs file
// Send the email
mailSender.sendEmail(emailData)
.then(result => {
if (result) {
console.log('Email sent successfully!');
} else {
console.log('Failed to send email.');
}
})
.catch(err => {
console.error('Error:', err);
});
try {
const result = await mailSender.sendEmail(emailData);
if (!result) {
console.log('Failed to send email.');
}
} catch (err) {
console.error('Error:', err);
}