latest: Points to the latest stable release (see above versions).<version>: Specific version tags (e.g., v1.2.3, v1.2.2, etc.).rolling: Points to the latest build (may be unstable), created daily without tests.testing: Developer image for testing the build process, not for production use.This container allows you to send simple emails from a Docker container using Alpine Linux and msmtp. It supports:
BODY_FILERun the container with the required environment variables:
docker run --rm \
-e SMTP_SERVER=smtp.example.com \
-e SMTP_PORT=25 \
-e [email protected] \
-e [email protected] \
-e SUBJECT="Notification from CI" \
-e BODY="Your job completed successfully." \
hldev/mailutil-alpine:latest
docker run --rm \
-e SMTP_SERVER=smtp.example.com \
-e SMTP_PORT=587 \
-e [email protected] \
-e SMTP_PASS=supersecret123 \
-e [email protected] \
-e [email protected] \
-e SUBJECT="Mail with Auth" \
-e BODY="This message uses SMTP authentication." \
hldev/mailutil-alpine:latest
docker run --rm \
-e SMTP_SERVER=mail.internal.example.com \
-e SMTP_PORT=25 \
-e [email protected] \
-e [email protected] \
-e SUBJECT="Skip TLS Check" \
-e BODY="This skips TLS certificate validation." \
-e TLS_CERTCHECK=off \
hldev/mailutil-alpine:latest
docker run --rm \
-v "$PWD/certs:/certs:ro" \
-e SMTP_SERVER=smtp.example.com \
-e SMTP_PORT=587 \
-e [email protected] \
-e [email protected] \
-e SUBJECT="Secure Mail" \
-e BODY="This email uses a mounted CA cert for TLS." \
-e TLS_CERT_PATH=/certs/smtp.pem \
hldev/mailutil-alpine:latest
BODY_FILE for Logs or Long Multiline ContentFor long logs or external files, you can pass the email body via a mounted file:
docker run --rm \
-v "$PWD/my-log.txt:/tmp/body.txt:ro" \
-e SMTP_SERVER=smtp.example.com \
-e SMTP_PORT=587 \
-e [email protected] \
-e SMTP_PASS=supersecret123 \
-e [email protected] \
-e [email protected] \
-e SUBJECT="Daily Report" \
-e BODY_FILE="/tmp/body.txt" \
hldev/mailutil-alpine:latest
This method is ideal for logs and large output, and preserves special characters and emojis like ๐ณ, โ
, or ๐ฅ.
Whether you use BODY or BODY_FILE, the container now fully supports UTF-8 content thanks to:
musl-locales + ENV LANG=C.UTF-8)Content-Type: text/plain; charset=UTF-8)8bit encoding supportYou can now safely write:
-e BODY="This is a โ
test message with symbols like ๐ณ and ๐"
.env FileAvoid exposing your credentials on the command line. Use a .env-mail file instead:
.env-mailSMTP_SERVER=smtp.example.com
SMTP_PORT=587
[email protected]
SMTP_PASS=supersecret123
[email protected]
[email protected]
MAIL_SUBJECT=GitLab Update Report - 2025-05-04
#!/bin/bash
. /srv/gitlab/.env-mail
LOGFILE="/srv/gitlab/logs/gitlab-update-$(date '+%Y-%m-%d_%H-%M-%S').log"
mkdir -p "$(dirname "$LOGFILE")"
echo "๐ณ GitLab updated successfully." >> "$LOGFILE"
docker run --rm \
-v "$LOGFILE:/tmp/body.txt:ro" \
-e SMTP_SERVER="$SMTP_SERVER" \
-e SMTP_PORT="$SMTP_PORT" \
-e SMTP_USER="$SMTP_USER" \
-e SMTP_PASS="$SMTP_PASS" \
-e FROM="$FROM" \
-e TO="$MAIL_TO" \
-e SUBJECT="$MAIL_SUBJECT" \
-e BODY_FILE="/tmp/body.txt" \
hldev/mailutil-alpine:latest
| Variable | Description |
|---|---|
SMTP_SERVER | SMTP host to connect to |
SMTP_PORT | Port number (usually 25 or 587) |
FROM | Sender email address |
TO | Recipient email address (or list) |
SUBJECT | Subject line of the email |
BODY | Body of the email (inline) |
| Variable | Description |
|---|---|
SMTP_USER | SMTP username (if authentication is needed) |
SMTP_PASS | SMTP password |
TLS_CERT_PATH | Path to mounted TLS CA cert (e.g. /certs/root.pem) |
TLS_CERTCHECK | Set to off to disable cert verification |
BODY_FILE | Path to a file that contains the full email body |
Alpine to 3.24.1msmtp to version 1.8.32Alpine to 3.23.4msmtp to version 1.8.32Alpine to 3.23.3msmtp to version 1.8.32Alpine to 3.23.2msmtp to version 1.8.32Alpine to 3.23.0msmtp to version 1.8.32Alpine to 3.22.2Alpine to 3.22.1Alpine to 3.22.0msmtp to version 1.8.28BODY_FILE environment variable to load email body from a mounted file..env usage.musl-locales and ENV LANG=C.UTF-8 for Unicode compatibility.Content-Type: text/plain; charset=UTF-8Content-Transfer-Encoding: 8bit-e BODY="..." for short inline messages-e BODY_FILE="..." with volume mount for full logsmsmtp for sending simple authenticated mailContent type
Image
Digest
sha256:3ed05ceeeโฆ
Size
9.2 MB
Last updated
3 months ago
docker pull hldev/mailutil-alpine