After running mailhook.app as a SaaS for 4.5 wonderful years, I've decided to make this simplified version available for free. This CLI tool provides the core functionality of Mailhook: receiving emails and forwarding them to webhooks.
- ๐จ SMTP Server for receiving emails
- ๐ Forward emails to webhook endpoints
- ๐ Support for email attachments (via S3)
- โก๏ธ Easy configuration with JSON
- ๐ Secure and reliable email processing
npm install -g mailhook-cli- Create a configuration file:
# Create config.json in your project directory
{
"mailhook": [
{
"email": "notifications@yourdomain.com",
"webhook": "https://api.example.com/webhook",
"method": "POST", # Optional, defaults to POST
"forwardAttachments": true
}
]
}- If using attachments, configure AWS (optional):
# .env file
AWS_ACCESS_KEY_ID=your_key
AWS_SECRET_ACCESS_KEY=your_secret
AWS_REGION=your_region
AWS_BUCKET_NAME=your_bucket- Start the server:
mailhookEach hook in the mailhook array supports:
| Field | Type | Required | Description |
|---|---|---|---|
email |
string | Yes | Email address to receive mail |
webhook |
string | Yes | Endpoint to forward emails |
method |
string | No | HTTP method (GET/POST, defaults to POST) |
forwardAttachments |
boolean | No | Enable S3 attachment forwarding |
| Variable | Required | Description |
|---|---|---|
SMTP_PORT |
No | SMTP port (default: 25) |
AWS_* |
If using attachments | AWS credentials for S3 |
Mailhook sends the following JSON payload to your webhook:
{
"id": string, // Unique identifier
"received_at": string, // ISO timestamp
"from": string[], // Sender email addresses
"to": string[], // Recipient email addresses
"subject": string, // Email subject
"text": string, // Plain text content
"html": string | null, // HTML content if available
"attachments": [ // Only if forwardAttachments is true
{
"filename": string,
"size": number,
"contentType": string,
"url": string // S3 public URL
}
]
}- Node.js 14 or later
- Available SMTP port (default: 25)
- AWS account (only for attachment handling)
- Receive notifications from services that only support email
- Build email automation workflows
- Test email-based features
- Process incoming emails in your applications
- Create email-to-webhook bridges
First, you need to configure your domain's DNS records to handle email properly. You'll need to add these records:
# MX Record - Tells email servers where to deliver mail
mailhook.app. IN MX 10 mail.mailhook.app.
# A Record - Points the mail subdomain to your server IP
mail.mailhook.app. IN A YOUR_SERVER_IP
# Optional but recommended:
# SPF Record - Helps prevent email spoofing
mailhook.app. IN TXT "v=spf1 mx ~all"
# Clone the repository
git clone https://github.com/camtosh/mailhook-cli
# Install dependencies
npm install
# Run in development mode
npm run dev
# Build
npm run build-
Attachments not working
- Verify AWS credentials
- Ensure S3 bucket has proper permissions
- Check
forwardAttachmentsis enabled
-
Port 25 blocked by cloud provider
- Many cloud providers block port 25 by default
- Contact support to unblock it
- Alternative: Use port 2525 and configure your DNS accordingly
-
Email not received
- Check DNS propagation (
dig MX mailhook.app) - Verify firewall settings
- Check service logs
- Check DNS propagation (
- Email filtering options
- Email validation rules
- Custom HTTP headers support
- Retry mechanisms for failed webhooks
This project is licensed for personal and non-commercial use only. Commercial use requires explicit permission. See LICENSE for details.
For commercial licensing: tochecamille@gmail.com
- Create an issue for bug reports
- For security concerns, email directly
- Commercial support available upon request
Thank you to all Mailhook customers who supported this project. This open-source version is dedicated to you.
Made with โค๏ธ by Camille Toche