All Projects → Turgon37 → docker-smtp-relay

Turgon37 / docker-smtp-relay

Licence: MIT license
Docker image running a SMTP relay with postfix

Programming Languages

shell
77523 projects
python
139335 projects - #7 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to docker-smtp-relay

docker-postfix-relay
SMTP server and SMTP relay host
Stars: ✭ 19 (-66.67%)
Mutual labels:  postfix, smtp-relay
Apex-Code-Conventions
Apex conventions and best practices for Salesforce Developers
Stars: ✭ 28 (-50.88%)
Mutual labels:  postfix
Docker Postfix
Simple SMTP relay docker image.
Stars: ✭ 162 (+184.21%)
Mutual labels:  postfix
SaorTech-cloud-services
A range of scripts to provision and configure open source cloud services.
Stars: ✭ 23 (-59.65%)
Mutual labels:  postfix
docker-postfix
Postfix Docker image. Read-only mirror of https://gitlab.com/tozd/docker/postfix
Stars: ✭ 23 (-59.65%)
Mutual labels:  postfix
xmpp-cloud-auth
🔑 Authentication hub for Nextcloud+JSXC→Prosody, ejabberd, saslauthd, Postfix
Stars: ✭ 58 (+1.75%)
Mutual labels:  postfix
Free Email Forwarding
The best free email forwarding for custom domains. Visit our website to get started (SMTP server)
Stars: ✭ 2,024 (+3450.88%)
Mutual labels:  postfix
mailserver
Simple and full-featured mail server using Docker
Stars: ✭ 88 (+54.39%)
Mutual labels:  postfix
ldap-mail-schema
a collection of LDAP mail schemas
Stars: ✭ 36 (-36.84%)
Mutual labels:  postfix
bacula-utils
A collect of tools to use with bacula
Stars: ✭ 36 (-36.84%)
Mutual labels:  postfix
smtprelay
Simple Golang SMTP relay/proxy server
Stars: ✭ 270 (+373.68%)
Mutual labels:  smtp-relay
magento2-server-configuration
Magento 2 server configuration -PHP7, Nginx, Postfix
Stars: ✭ 68 (+19.3%)
Mutual labels:  postfix
Hermes-Secure-Email-Gateway
Hermes Secure Email Gateway is a Free Open Source Ubuntu 18.04 or 20.04 Server based Email Gateway that provides Spam, Virus and Malware protection, full in-transit and at-rest email encryption as well as email archiving. It features the latest email authentication techniques such as SPF, DKIM and DMARC.
Stars: ✭ 35 (-38.6%)
Mutual labels:  postfix
Docker Postfix
Simple SMTP server / postfix null relay host for your Docker and Kubernetes containers. Based on Alpine Linux.
Stars: ✭ 163 (+185.96%)
Mutual labels:  postfix
vscode-postfix-ts
Postfix notation for TypeScript/Javascript - extension for VS Code
Stars: ✭ 112 (+96.49%)
Mutual labels:  postfix
Modoboa Installer
An installer for Modoboa
Stars: ✭ 161 (+182.46%)
Mutual labels:  postfix
mailfull-go
A management tool for virtual domain email for Postfix and Dovecot written in Go
Stars: ✭ 20 (-64.91%)
Mutual labels:  postfix
pymailq
Simple mails queue management
Stars: ✭ 32 (-43.86%)
Mutual labels:  postfix
postfixadmin-cookbook
Chef cookbook to install and configure PostfixAdmin.
Stars: ✭ 13 (-77.19%)
Mutual labels:  postfix
webadmin
SophiMail Webadmin and Dashboard
Stars: ✭ 48 (-15.79%)
Mutual labels:  postfix

Docker SMTP Relay

Build Status

This image contains an instance of Postfix SMTP server configured as a SMTP relay. This relay is restricted to only one domain name. so it means that only mail that come from RELAY_MYDOMAIN will be relayed to the relayhost.

⚠️ Take care of the changelogs because some breaking changes may happend between versions.

Supported tags, image variants and respective Dockerfile links

Example of usage

This relay can take place into a information system if you want to give access to some web or other applications a way to send notification by mail.

The advantage of this configuration is that only the host in theses case are allowed to send emails through this relay :

  • The host IP's address is in the range of RELAY_MYNETWORKS
  • The host is authenticated with a valid SASL login/password

Docker Informations

  • This port is available on this image
Port Usage
25 SMTP for incoming relay user
  • This volume is bind on this image
Volume Usage
/data Contains the flat database that contains all SASL user
/var/spool/postfix Where postfix store mail queue (to persist not yet delivered mails across container restart)
  • This image takes theses environnements variables as parameters
Environment Type Usage
RELAY_MYHOSTNAME String The hostname of the SMTP relay (because docker assign a random hostname, you can specify here a human-readable hostname)
RELAY_MYDOMAIN (mandatory) String The domain name that this relay will forward the mail
RELAY_MYNETWORKS List of strings The space separated list of network(s) which are allowed by default to relay emails
RELAY_DOMAINS List of strings The space separated list of external domain names for whose this relay will forward email. Useless if you use a *NODOMAIN relay mode. Default to RELAY_MYDOMAIN
RELAY_HOST (mandatory) String The remote host to which send the relayed emails (the relayhost)
RELAY_LOGIN String The login name to present to the relayhost during authentication (optional)
RELAY_PASSWORD String The password to present to the relayhost during authentication (optional)
RELAY_USE_TLS Boolean(yes/no) Specify if you want to require a TLS connection to relayhost
RELAY_TLS_VERIFY Enum How to verify the TLS : (none, may, encrypt, dane, dane-only, fingerprint, verify, secure)
RELAY_TLS_CA String path The path (in the container) to the CA file use to check relayhost certificate (Default: /etc/ssl/certs/ca-certificates.crt)
RELAY_POSTMASTER String email address The email address of the postmaster, in order to send error, and misconfiguration notification
RELAY_STRICT_SENDER_MYDOMAIN Boolean(true/false) If set to 'true' all sender addresses must belong to the relay domains
RELAY_MODE Enum The predefined mode of relay behaviour, theses modes has been designed by me. See below for available values
RELAY_EXTRAS_SETTINGS List of string (deprecated use POSTCONF_ below) Space separated of extras options that will be passed to postconf -e
POSTCONF_[custom] Mixed Set any available postconf value (see example below)

Relay Mode

Description of available relay modes

Relay mode value Description Usage
STRICT Only network and sasl authenticated users can send emails through relay. All emails must have a recipient adress which belong to the relay domains Typically you can use this mode to allow one of your application to send email to internals domain emails adresses
ALLOW_SASLAUTH_NODOMAIN Only network and sasl authenticated users can send emails through relay. All emails send by network authenticated users must have a recipient adress which belong to the relay domains. All emails send by sasl authenticated users can have any recipient adress(es). You can use this mode to allow one of your (internal) application to send email to external users. In case when some part(s) of your application will be reachable by externals users
ALLOW_NETAUTH_NODOMAIN Only network and sasl authenticated users can send emails through relay. All emails send by sasl authenticated users must have a recipient adress which belong to the relay domains. All emails send by network authenticated users can have any recipient adress(es)
ALLOW_AUTH_NODOMAIN Only network and sasl authenticated users can send emails through relay. All emails send by all authenticated users can have any recipient adress(es). In case where you want a simple relay host with a basic auth

For other examples of values, you can refer to the Dockerfile

Todo

Installation

  • Manual
git clone
./build.sh
  • or Automatic
docker pull turgon37/smtp-relay

Usage

docker run -p 25:25 -e "RELAY_MYDOMAIN=domain.com" -e "RELAY_HOST=relay:25" turgon37/smtp-relay

Docker-compose Specific configuration examples

  • unauthenticated smtp relay filtered by subnet and domain name
services:
  smtp-relay:
    image: turgon37/smtp-relay:latest
    environment:
      RELAY_POSTMASTER: '[email protected]'
      RELAY_MYHOSTNAME: 'smtp-relay.example.net'
      RELAY_MYDOMAIN: 'example.net'
      RELAY_MYNETWORKS: '127.0.0.0/8 10.0.0.0/24'
      RELAY_HOST: '[10.1.0.1]:25'
    ports:
      - "10.0.0.1:3000:25"
  • authenticated smtp proxy
services:
  smtp-relay-auth:
    image: turgon37/smtp-relay:latest
    environment:
      RELAY_POSTMASTER: '[email protected]'
      RELAY_MYHOSTNAME: 'smtp-relay.example.net'
      RELAY_MYDOMAIN: 'example.net'
      RELAY_MYNETWORKS: '127.0.0.0/8 10.0.0.0/24'
      RELAY_HOST: '[10.1.0.1]:25'
      RELAY_MODE: 'ALLOW_SASLAUTH_NODOMAIN'
      RELAY_LOGIN: 'sasl-user-login'
      RELAY_PASSWORD: 'xxxxxxxxxxxx'
      RELAY_USE_TLS: 'no'
      POSTCONF_compatibility_level: '2'
    ports:
      - "10.0.0.1:3000:25"
    volumes:
      - data-smtp-relay-auth:/data
      - data-smtp-relay-queue:/var/spool/postfix
volumes:
  data-smtp-relay-auth:
  data-smtp-relay-queue:

Using external relay credentials

If you want to prevent having your relay credentials in your docker-compose file, you can mount them (instead of setting RELAY_LOGINand RELAY_PASSWORD variables) into /etc/postfix/sasl_passwd

Taking again our authenticated smtp proxy example above, we would now have:

services:
  smtp-relay-auth:
    image: turgon37/smtp-relay:latest
    environment:
      RELAY_POSTMASTER: '[email protected]'
      RELAY_MYHOSTNAME: 'smtp-relay.example.net'
      RELAY_MYDOMAIN: 'example.net'
      RELAY_MYNETWORKS: '127.0.0.0/8 10.0.0.0/24'
      RELAY_HOST: '[10.1.0.1]:25'
      RELAY_MODE: ALLOW_SASLAUTH_NODOMAIN
      RELAY_USE_TLS: 'no'
      POSTCONF_compatibility_level: '2'
    ports:
      - "10.0.0.1:3000:25"
    volumes:
      - data-smtp-relay-auth:/data
      - "/my/local/path/sasl_passwd:/etc/postfix/sasl_passwd"
volumes:
  data-smtp-relay-auth:

And our local sasl_passwd file would have as contents:

user@host:~$cat /my/local/path/sasl_passwd
[10.1.0.1]:25 sasl-user-login:xxxxxxxxxxxx  

Configuration during runtime

  • List all SASL users :
docker exec smtp-relay /opt/listpasswd.sh
  • Add a SASL user :

If you have a host which is not in the range of addresses specified in 'mynetworks' of postfix, this host have to be sasl authenticated when it connects to the smtp relay.

To create a generic account for this host you have to run this command into the container

docker exec -it smtp-relay /opt/saslpasswd.sh -u domain.com -c username

You have to replace domain.com with your relay domain and you will be prompt for password two times. Then you will be prompted for password two times

  • Add multiple SASL users :

If you want to add multiple sasl users at the same time you can mount (-v) your credentials list to /etc/postfix/client_sasl_passwd This list must contains one credential per line and for each line use the syntax 'USERNAME PASSWORD' (the username and the password are separated with a blank space)

You can check with docker logs if all of your line has been correctly parsed

Troubleshooting

An simple SMTP client is embedded with this image. You can use it to test your settings

docker exec -it smtp-relay /opt/smtp_client.py -s test -f [email protected] --user user1:password1 [email protected]
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].