Skip to content

Latest commit

 

History

History
93 lines (70 loc) · 2.2 KB

README.md

File metadata and controls

93 lines (70 loc) · 2.2 KB

SMTP Firewall

SMTP Firewall serves as a sidecar container alongside your primary application. It filters emails before they reach your email service provider.

Key features:

  • Rate Limit with a mail queue
  • Dropping emails if the app sends too frequently to a single recipient
  • Bad Domain Filter
  • Support SMTP and multiple email service providers

Getting started

Using a Docker Compose file

Instead of running SMTP Firewall as a sidecar in a Kubernetes Pod, you may make use of Docker Compose to try running it.

version: '3'

services:
  smtp:
    image: rnwood/smtp4dev
    ports:
      - 3000:80
  smtp_firewall:
    image: relatedbits/smtp-firewall
    environment:
      FILTER_BAD_DOMAIN_ENABLED: true
  app:
    image: YOUR_APPLICATION_IMAGE # Replace with your app image
    environment:
      SMTP_HOST: smtp_firewall # Set SMTP Host
      SMTP_PORT: 1025          # Set SMTP Port

Launch the containers using:

docker compose up -d

Open your application and send an email.

You may then open http://localhost:3000 to see if the email is being dropped.

Prepare an email blacklist

SMTP Firewall reads from bad_domains.txt for the email blacklist. Each line in the file represents a domain name.

You may start from downloading email blacklist online:

Select an email service proviers

SMTP

Environment variables:

Variable Value(example)
SENDER_TYPE smtp
SENDER_SMTP_ADDR smtp:25

AWS SES

Environment variables:

Variable Value(example)
SENDER_TYPE awsses
SENDER_AWSSES_TIMEOUT 5

Mailjet

Environment variables:

Variable Value(example)
SENDER_TYPE mailjet
SENDER_MAILJET_BASEURL (Leave it blank to apply the default base URL defined by official library)
SENDER_MAILJET_APIKEY_PUBLIC APIKEY_PUBLIC
SENDER_MAILJET_APIKEY_PRIVATE APIKEY_PRIVATE

Configuration

Environment variables

Variable Default Value
SMTP_SERVER_ADDR 0.0.0.0:1025
SMTP_SERVER_ALLOW_INSECURE_AUTH true
FILTER_BAD_DOMAIN_ENABLED false
RATELIMIT 10
QUEUE_CAPACITY 100
TIMEDMAP_COOLDOWN_SECONDS_FOR_SINGLE_RECIPIENT 30
TIMEDMAP_CLEANUP_PER_N_SECOND 60