Sign inSign up

relatedbits/smtp-firewall

By relatedbits

Updated over 2 years ago

SMTP sidecar to filter emails before they reach your email service provider such as AWS SES, Mailjet

Image
0

706

relatedbits/smtp-firewall repository overview

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:

VariableValue(example)
SENDER_TYPEsmtp
SENDER_SMTP_ADDRsmtp:25
AWS SES

Environment variables:

VariableValue(example)
SENDER_TYPEawsses
SENDER_AWSSES_TIMEOUT5
Mailjet

Environment variables:

VariableValue(example)
SENDER_TYPEmailjet
SENDER_MAILJET_BASEURL(Leave it blank to apply the default base URL defined by official library)
SENDER_MAILJET_APIKEY_PUBLICAPIKEY_PUBLIC
SENDER_MAILJET_APIKEY_PRIVATEAPIKEY_PRIVATE

Configuration

Environment variables
VariableDefault Value
SMTP_SERVER_ADDR0.0.0.0:1025
SMTP_SERVER_ALLOW_INSECURE_AUTHtrue
FILTER_BAD_DOMAIN_ENABLEDfalse
RATELIMIT10
QUEUE_CAPACITY100
TIMEDMAP_COOLDOWN_SECONDS_FOR_SINGLE_RECIPIENT30
TIMEDMAP_CLEANUP_PER_N_SECOND60

Tag summary

Content type

Image

Digest

sha256:920a5599f

Size

7.3 MB

Last updated

over 2 years ago

docker pull relatedbits/smtp-firewall