Security
TLS
- The web client is served over HTTPS with a Let's Encrypt certificate, renewed 30 days before it ends without a restart.
- SMTP and IMAP use the same certificate: implicit TLS on 465 and 993, STARTTLS on 587 and 25.
- Mail programs cannot send passwords over an unencrypted connection (
SMTP_AUTH_WITHOUT_TLSandIMAP_AUTH_WITHOUT_TLSare for closed test networks only). - Without a certificate the server makes a self-signed one and switches to the real one as soon as it appears.
Passwords
- The web password works only in the web client. Mail programs use app passwords, each bound to one mailbox and deletable on its own (Mail programs).
- Passwords are at least 8 characters and stored as hashes.
Password guessing protection
One counter for every place a password is checked: SMTP AUTH, IMAP LOGIN, the web login and password change.
- By IP: 10 wrong passwords in 15 minutes block the IP for 15 minutes; the next block lasts 30 minutes, then an hour… up to a day. A quiet day resets the count.
- By mailbox: 20 wrong passwords for one mailbox from different IPs (a distributed attack) close the mailbox for 15 minutes — except for IPs that logged in successfully in the last 30 days, so an attacker cannot lock the owner out of their own mail program.
- During a block the password is not checked at all: SMTP answers
421 4.7.0and closes, IMAPBYE, the web429withRetry-After. A wrong password is answered after a second; three wrong ones close the SMTP or IMAP connection. - "No such mailbox" and "wrong password" look the same from outside.
- The log says
login guard: IP … blocked for 15 min after 10 failed logins (block #1).
Limits are set with the LOGIN_GUARD_* variables (Configuration).
Incoming mail
- SPF and DMARC of the sender's domain, DKIM signatures.
- Spam block lists (
SPAM_DNSBL): mail from a listed address goes to Spam. - Mail that claims to come from your own domain without a valid signature goes to Spam.
- Each user keeps a blacklist of senders.
Outgoing mail
- Every message from your domains is DKIM-signed.
- A limit per mailbox per hour (
OUTBOUND_MAX_PER_HOUR) stops a stolen password from turning the server into a spam source and ruining its reputation.
Metrics
/actuator/prometheus and /actuator/metrics answer only with Authorization: Bearer <METRICS_TOKEN>; without
METRICS_TOKEN they are closed. /actuator/health is open.
| Metric | What |
|---|---|
mail.queue.pending | messages waiting to go out |
mail.queue.oldest.seconds | age of the oldest one |
mail.delivery{outcome} | delivery attempts: delivered, retry, failed |
mail.login.failures | wrong passwords (SMTP, IMAP, web) |
mail.login.blocks{kind} | blocks: ip, mailbox |
mail.tls.certificate.expiry | seconds until the certificate ends |
mail.tls.certificate.selfsigned | 1 while a self-signed certificate is used |
An alert worth having — the certificate is renewed 30 days before its end, so less than 20 days means renewal is broken:
- alert: MailCertificateExpiresSoon
expr: mail_tls_certificate_expiry_seconds < 20 * 86400 or mail_tls_certificate_selfsigned == 1
for: 1h