send-email-utility-function
v1.0.1
Published
A simple utility for sending emails using Node.js and Nodemailer.
Maintainers
Readme
send-email-utility-function
A simple utility for sending emails using Node.js and Nodemailer. ✉️🚀
📦 Installation
npm install send-email-utility-function🛠️ Usage
const { sendEmail } = require('send-email-utility-function');
sendEmail({
to: '[email protected]',
subject: 'Hello World',
html: '<h1>Hello World</h1>',
}).then(info => {
console.log('Email sent:', info.messageId);
}).catch(error => {
console.error('Error sending email:', error);
});⚙️ Environment Variables
Make sure to set the following environment variables:
EMAIL_USER: Your email address 📧EMAIL_PASSWORD: Your email password or app password 🔑
🔑 How to Get a Gmail App Password
If you use Gmail, you need an App Password instead of your regular password. Here’s how to get one:
Go to your Google Account
👉 Google AccountEnable 2-Step Verification
🔒 Go to Security > 2-Step Verification
🟢 Turn it ON (if not already enabled)Generate an App Password
🔑 In Security, find App passwords
(You may need to sign in again)Create a new App Password
➕ Select Mail as the app
💻 Select your device (or choose "Other" and name it)Copy the 16-character password
📋 Copy it and use it as yourEMAIL_PASSWORDin your environment variables
⚠️ Keep your app password safe!
You only need to enter it once in your .env file or environment settings.
📄 License
MIT
