ezymail
v3.0.0
Published
A simple and easy-to-use email sending library for Node.js.
Readme
ezymail
A lightweight email-sending package built from scratch using raw SMTP, TLS, and Node.js sockets.
No heavy dependencies. No SMTP wrappers. Just direct protocol-level email handling.
Features
- Raw SMTP communication
- TLS-secured email sending
- Promise-based API
- Supports plain text and HTML emails
- Minimal and lightweight
- Built for learning and experimentation
Installation
npm install ezymailUsage
const ezymail = require("ezymail");
ezymail.send({
from: "[email protected]",
to: "[email protected]",
subject: "Test Email",
html: "<p>Hello from ezymail</p>",
user: "[email protected]",
pass: "your_app_password"
})
// For sequential/concurrent bulk mail sending :)
const data = {
from: "[email protected]",
subject: "Test Email",
html: "<p>Hello from ezymail</p>",
user: "[email protected]",
pass: "your_app_password"
}
// "to" will automatically be taken from the users array
const users = [
"[email protected]",
"[email protected]"
]
// Make sure to use your SMTP email and app password
ezymail.sendseqmail(users, data, n)
// n = maximum number of mails to send (cap on the users array)
//
// Internally, mails are processed in batches of 20,
// with 5 mails sent concurrently within each batch.
//
// Example with 100 users, n = 60:
// -> only the first 60 users are processed
// -> split into 3 batches of 20
// -> each batch sends 5 mails at a time until the batch is done
// -> next batch starts only after the previous one completes
//
// sendseqmail takes each user from the users array,
// combines it with the provided data,
// and sends the mail to that respective user.
If you call the HTTP API directly, send valid JSON with double-quoted keys:
```json
{
"from": "[email protected]",
"to": "[email protected]",
"subject": "Hello",
"html": "<h1>Hello from ezymail</h1>"
}Parameters
| Field | Type | Required | Description | |-----------|--------|----------|-------------| | from | string | Yes | Sender email address | | to | string | Yes | Recipient email address | | subject | string | Yes | Email subject | | html | string | Yes | Email content (sned html) | | user | string | Yes | SMTP username | | pass | string | Yes | SMTP password or App Password |
Gmail Setup
To use Gmail SMTP:
- Enable 2-Step Verification
- Generate an App Password
- Use the App Password instead of your real password
Google may block insecure or suspicious SMTP logins from some cloud platforms.
Example
const ezymail = require("ezymail");
ezymail.send({
from: "[email protected]",
to: "[email protected]",
subject: "Hello",
html: "<h1>Hello from ezymail</h1>",
user: "[email protected]",
pass: "your_app_password"
})
// For sequential/concurrent bulk mail sending :)
const data = {
from: "[email protected]",
subject: "Test Email",
html: "<p>Hello from ezymail</p>",
user: "[email protected]",
pass: "your_app_password"
}
// "to" will automatically be taken from the users array
const users = [
"[email protected]",
"[email protected]"
]
// Make sure to use your SMTP email and app password
ezymail.sendseqmail(users, data, n)
// n = maximum number of mails to send (cap on the users array)
//
// Internally, mails are processed in batches of 20,
// with 5 mails sent concurrently within each batch.
//
// Example with 100 users, n = 60:
// -> only the first 60 users are processed
// -> split into 3 batches of 20
// -> each batch sends 5 mails at a time until the batch is done
// -> next batch starts only after the previous one completes
//
// sendseqmail takes each user from the users array,
// combines it with the provided data,
// and sends the mail to that respective user.How It Works
ezymail manually implements the SMTP protocol:
- Connects to the SMTP server
- Establishes a TLS-secured connection
- Authenticates using
AUTH LOGIN - Sends SMTP commands directly
- Delivers the email
- Closes the connection
Deployment Notes
Some serverless platforms block outbound SMTP ports such as:
- 25
- 465
- 587
Because of this, raw SMTP may not work on platforms like:
- Vercel
- Netlify
- Cloudflare Workers
For production deployments, it is recommended to use:
- VPS hosting
- Dedicated servers
- Or an API-based mail transport layer
Limitations
- No attachments yet
- No connection pooling
- Basic SMTP parsing
- Limited provider compatibility
- SMTP ports may be blocked on some cloud platforms
Why This Package Exists
ezymail is primarily built for:
- Learning how SMTP works internally
- Understanding TLS and sockets
- Exploring low-level networking
- Building custom mail infrastructure
It is not intended to fully replace mature solutions like Nodemailer.
Security Notes
- Never expose SMTP credentials publicly
- Always use App Passwords instead of your real password
- Do not hardcode credentials inside source code
- Use environment variables in production
Example:
[email protected]
PASSWORD=your_app_passwordLicense
MIT
