Skip to content

StefanKnol/Webhook-Mailer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Webhook Mailer

A simple Node.js application that receives webhook notifications and sends emails via SMTP.

Setup

  1. Copy the environment template and configure your SMTP settings:

    cp .env.example .env
  2. Edit .env with your SMTP credentials:

    SMTP_HOST=smtp.gmail.com
    SMTP_PORT=587
    SMTP_SECURE=false
    [email protected]
    SMTP_PASS=your-app-password
    
    [email protected]
    [email protected]
    
    PORT=3000
    WEBHOOK_SECRET=your-secret-key
    
  3. Install dependencies:

    npm install
  4. Start the server:

    npm start

Usage

Send a POST request to the webhook endpoint:

curl -X POST http://localhost:3000/webhook \
  -H "Content-Type: application/json" \
  -H "X-Webhook-Secret: your-secret-key" \
  -d '{
    "subject": "Test Notification",
    "body": "This is a test email from the webhook."
  }'

Webhook Payload Options

Field Required Description
subject Yes* Email subject line
body Yes* Plain text email body
html No HTML email body (optional)
to No Override default recipient

*At least subject or body must be provided.

Authentication (Optional)

Authentication is disabled by default. To enable it, set WEBHOOK_SECRET in your .env file.

When enabled, include your secret in either:

  • Header: X-Webhook-Secret: your-secret
  • Query parameter: ?secret=your-secret

To disable authentication, leave WEBHOOK_SECRET empty or remove it.

Endpoints

  • GET /health - Health check
  • POST /webhook - Main webhook endpoint

SMTP Providers

Common SMTP configurations:

Gmail (requires App Password):

SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_SECURE=false

Outlook/Hotmail:

SMTP_HOST=smtp-mail.outlook.com
SMTP_PORT=587
SMTP_SECURE=false

Custom SMTP:

SMTP_HOST=mail.yourdomain.com
SMTP_PORT=465
SMTP_SECURE=true

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors