smtpsend-cli
v1.0.1
Published
A simple and lightweight CLI tool to send emails via SMTP
Maintainers
Readme
smtpsend-cli
A simple and lightweight CLI tool to send emails via SMTP from the command line.
Installation
npm install -g smtpsend-cliUsage
Basic Usage
smtpsend --host smtp.gmail.com --port 587 --user [email protected] --password your-password --to [email protected]With Subject and Text
smtpsend \
--host smtp.gmail.com \
--port 587 \
--user [email protected] \
--password your-password \
--to [email protected] \
--subject "Hello from CLI" \
--text "This is the email body"With HTML Content
smtpsend \
--host smtp.gmail.com \
--port 587 \
--user [email protected] \
--password your-password \
--to [email protected] \
--subject "HTML Email" \
--html "<h1>Hello</h1><p>This is HTML content</p>"Using Environment Variables
Create a .env file or export environment variables:
export SMTP_HOST=smtp.gmail.com
export SMTP_PORT=587
export SMTP_SECURE=false
export [email protected]
export SMTP_PASSWORD=your-password
export [email protected]Then you only need to specify --to:
smtpsend --to [email protected]Options
| Option | Short | Description | Required | Default |
|--------|-------|-------------|----------|---------|
| --to | -t | Recipient email address | ✅ Yes | - |
| --host | -h | SMTP host | ✅ Yes* | SMTP_HOST env var |
| --port | -p | SMTP port | No | 587 or SMTP_PORT env var |
| --secure | -s | Use secure connection (true/false) | No | false or SMTP_SECURE env var |
| --user | -u | SMTP username | ✅ Yes* | SMTP_USER env var |
| --password | -w | SMTP password | ✅ Yes* | SMTP_PASSWORD env var |
| --from | -f | From email address | No | SMTP_FROM env var or --user value |
| --subject | - | Email subject | No | Test Email |
| --text | - | Email text content | No | This is a test email sent via smtpsend CLI. |
| --html | - | Email HTML content | No | - |
* Required if not set via environment variables
Examples
Gmail
smtpsend \
--host smtp.gmail.com \
--port 587 \
--user [email protected] \
--password your-app-password \
--to [email protected]Note: For Gmail, you need to use an App Password instead of your regular password.
Outlook
smtpsend \
--host smtp-mail.outlook.com \
--port 587 \
--user [email protected] \
--password your-password \
--to [email protected]SendGrid
smtpsend \
--host smtp.sendgrid.net \
--port 587 \
--user apikey \
--password YOUR_SENDGRID_API_KEY \
--from [email protected] \
--to [email protected]Mailgun
smtpsend \
--host smtp.mailgun.org \
--port 587 \
--user YOUR_MAILGUN_SMTP_USER \
--password YOUR_MAILGUN_SMTP_PASSWORD \
--to [email protected]Common SMTP Providers
| Provider | Host | Port | Secure |
|----------|------|------|--------|
| Gmail | smtp.gmail.com | 587 | false |
| Gmail (SSL) | smtp.gmail.com | 465 | true |
| Outlook | smtp-mail.outlook.com | 587 | false |
| Yahoo | smtp.mail.yahoo.com | 587 | false |
| SendGrid | smtp.sendgrid.net | 587 | false |
| Mailgun | smtp.mailgun.org | 587 | false |
Requirements
- Node.js >= 18.0.0
License
MIT
