Skip to content

Lightweight SMTP relay Docker image using msmtpd

License

Notifications You must be signed in to change notification settings

thib3113/docker-msmtpd

 
 

Repository files navigation

Latest Version Build Status Docker Stars Docker Pulls
Become a sponsor Donate Paypal

About

Lightweight SMTP relay using msmtpd as a Docker image.

Tip

Want to be notified of new releases? Check out 🔔 Diun (Docker Image Update Notifier) project!


Features

Build locally

git clone https://github.com/crazy-max/docker-msmtpd.git
cd docker-msmtpd

# Build image and output to docker (default)
docker buildx bake

# Build multi-platform image
docker buildx bake image-all

Image

Registry Image
Docker Hub crazymax/msmtpd
GitHub Container Registry ghcr.io/crazy-max/msmtpd

Following platforms for this image are available:

$ docker run --rm mplatform/mquery crazymax/msmtpd:latest
Image: crazymax/msmtpd:latest
 * Manifest List: Yes
 * Supported platforms:
   - linux/amd64
   - linux/arm/v6
   - linux/arm/v7
   - linux/arm64
   - linux/386
   - linux/ppc64le
   - linux/s390x

Environment variables

  • TZ: Timezone assigned to the container (default UTC)
  • PUID: Daemon user id (default 1500)
  • PGID: Daemon group id (default 1500)
  • MSMTP_USER : Username to authenticate on the msmtp smtp. Also support file to fill value : MSMTP_USER_FILE
  • MSMTP_PASSWORD : Password to authenticate on the msmtp smtp. Also support file to fill value : MSMTP_PASSWORD_FILE

Next variables are splitted by accounts following this template :

SMTP_<account>_<configuration>

default account is named default, here are some env with the default account :

  • SMTP_DEFAULT_HOST: SMTP relay server to send the mail to. required
  • SMTP_DEFAULT_PORT: Port that the SMTP relay server listens on. Default 25 or 465 if TLS.
  • SMTP_DEFAULT_TLS: Enable or disable TLS (also known as SSL) for secured connections (on or off).
  • SMTP_DEFAULT_TLS_STARTTLS: Start TLS from within the session (on, default), or tunnel the session through TLS (off).
  • SMTP_DEFAULT_TLS_CERTCHECK: Enable or disable checks of the server certificate (on or off). They are enabled by default.
  • SMTP_DEFAULT_AUTH: Enable or disable authentication and optionally choose a method to use. The argument on chooses a method automatically.
  • SMTP_DEFAULT_USER: Set the username for authentication. Authentication must be activated with the SMTP_AUTH env var.
  • SMTP_DEFAULT_PASSWORD: Set the password for authentication. Authentication must be activated with the SMTP_AUTH env var.
  • SMTP_DEFAULT_DOMAIN: Argument of the SMTP EHLO command (default localhost)
  • SMTP_DEFAULT_FROM: Set the envelope-from address. Supported substitution patterns can be found here.
  • SMTP_DEFAULT_SET_FROM_HEADER: When to set a From header. Can be auto, on or off (default auto)
  • SMTP_DEFAULT_SET_DATE_HEADER: When to set a Date header. Can be auto or off (default auto)
  • SMTP_DEFAULT_REMOVE_BCC_HEADERS: Controls whether to remove Bcc headers. Can be on or off (default on)
  • SMTP_DEFAULT_UNDISCLOSED_RECIPIENTS: When set, the original To, Cc, and Bcc headers of the mail are removed and a single new header line To: undisclosed-recipients:; is added. Can be on or off (default off)
  • SMTP_DEFAULT_DSN_NOTIFY: Set the condition(s) under which the mail system should send DSN (Delivery Status Notification) messages as comma separated values. Available values are off, never, failure, delay and success (default off)
  • SMTP_DEFAULT_DSN_RETURN: Controls how much of a mail should be returned in DSN (Delivery Status Notification) messages. Can be headers, full or off (default off)

💡 All the available configurations are here : https://marlam.de/msmtp/msmtp.html

💡 SMTP_<account>_USER_FILE and SMTP_<account>_PASSWORD_FILE can be used to fill in the value from a file, especially for Docker's secrets feature.

You can also use inherit to extend an existing configuration :

  • SMTP_TEST2_INHERIT: allow to inherit one or more configurations . Need to be a list of existing accounts, coma separated : DEFAULT, TEST, TEST1

Ports

  • 2500: SMTP relay port

Configuration by file mapping

You can add configuration by mapping a configuration file to /root/.msmtprc

You will always need to configure DEFAULT account with environment variables

Usage

Docker Compose

Docker compose is the recommended way to run this image. You can use the following docker compose template, then run the container:

docker compose up -d
docker compose logs -f

Kubernetes

To install on a Kubernetes cluster, you can use the following kubernetes deployment template, then create the deployment:

kubectl apply -f deployment.yaml

Command line

You can also use the following minimal command:

$ docker run -d -p 2500:2500 --name msmtpd \
  -e "SMTP_DEFAULT_HOST=smtp.example.com" \
  crazymax/msmtpd

Upgrade

Recreate the container whenever I push an update:

docker compose pull
docker compose up -d

Contributing

Want to contribute? Awesome! The most basic way to show your support is to star the project, or to raise issues. You can also support this project by becoming a sponsor on GitHub or by making a PayPal donation to ensure this journey continues indefinitely!

Thanks again for your support, it is much appreciated! 🙏

License

MIT. See LICENSE for more details.

About

Lightweight SMTP relay Docker image using msmtpd

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dockerfile 70.9%
  • HCL 29.1%