Skip to main content
GrN.dk

Main navigation

  • Articles
  • Cases
  • Contact
  • Your Digital Project Manager
  • About Greg Nowak
  • Services
  • Portfolio
  • Container
    • Excel Freelancer
    • Kubuntu - tips and tricks
    • Linux Apache MySQL and PHP
    • News
    • Image Gallery
User account menu
  • Log in

Join my community / free newsletter — sign up here

Breadcrumb

  1. Home

Enable TLS on a Linux Mail Server Without Breaking Delivery

By Greg Nowak. Updated 1 August 2026.

Mail-server TLS is not a switch you turn on once. Public SMTP, authenticated submission and mailbox access have different security requirements. Apply one strict policy everywhere and legitimate mail may stop arriving; leave everything optional and users or applications may expose credentials.

There is also a business decision to make first. If a server only sends website forms, password resets or application alerts, an established SMTP provider will often be easier to operate than a public mail server. Running your own MX makes more sense when you need direct control of inbound delivery, mailboxes or a specialised routing policy—and can commit to monitoring it.

Choose the TLS policy by service

Service Typical port Recommended posture Main risk
Public SMTP receiver 25 Offer STARTTLS; allow fallback Mandatory TLS can reject legitimate senders
Authenticated submission 587 Require STARTTLS before authentication Credentials exposed by an incorrect AUTH policy
Implicit TLS submission 465 Encrypt from connection start Clients configured for the wrong mode
IMAP mailbox access 993 Require TLS Certificate-name errors and exposed passwords
The safe policy depends on the service. Public server-to-server SMTP cannot be treated like a controlled user login.

Keep public SMTP opportunistic

On a publicly referenced MX, Postfix should advertise STARTTLS without requiring every sending server to use it. The may policy encrypts when the other system supports TLS but preserves delivery compatibility when it does not.

# /etc/postfix/main.cf
smtpd_tls_security_level = may
smtp_tls_security_level = may
smtpd_tls_cert_file = /etc/letsencrypt/live/mail.example.com/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/mail.example.com/privkey.pem

The first setting covers mail arriving at your server. The second enables opportunistic TLS for outbound delivery. If you send through a controlled relay, configure a stricter outbound policy for that destination rather than assuming the open internet can always meet it.

Require encryption on authenticated submission

Port 587 serves users and applications that authenticate. Make TLS mandatory there and do not advertise AUTH before encryption. Keep these overrides in master.cf so the stricter policy does not leak onto port 25.

# /etc/postfix/master.cf
submission inet n - y - - smtpd
  -o smtpd_tls_security_level=encrypt
  -o smtpd_tls_auth_only=yes
  -o smtpd_sasl_auth_enable=yes

The precise service line can differ between Linux packages, so compare it with the distribution’s supplied master.cf. Confirm that SASL is connected to the intended authentication service and that submission is not accidentally configured as an unauthenticated relay.

Match Dovecot configuration to its installed version

Postfix TLS does not protect IMAP or POP logins. For Dovecot 2.4, the relevant server certificate settings are ssl_server_cert_file and ssl_server_key_file:

# Dovecot 2.4
ssl = required
auth_allow_cleartext = no
ssl_server_cert_file = /etc/letsencrypt/live/mail.example.com/fullchain.pem
ssl_server_key_file = /etc/letsencrypt/live/mail.example.com/privkey.pem

Dovecot 2.3 uses different setting names and syntax. Check dovecot --version before copying a configuration block, especially on long-term-support distributions. Then inspect the effective configuration with doveconf -n. Keep the private key readable only by root or the narrowly scoped system group that needs it.

Treat renewal and reload as one operation

A renewed certificate does nothing until Postfix and Dovecot start using the new files. Obtain the certificate with an authenticator appropriate to the host, test renewal, and install an executable deploy hook that reloads both services after a successful renewal.

sudo certbot certonly --webroot -w /var/www/html -d mail.example.com
sudo certbot renew --dry-run --run-deploy-hooks

A deploy-hook script in /etc/letsencrypt/renewal-hooks/deploy/ can contain:

#!/bin/sh
systemctl reload postfix
systemctl reload dovecot

Certbot does not run deploy hooks during a normal dry run unless --run-deploy-hooks is supplied. Test the hook during a controlled change window, confirm both reload commands succeed, and monitor certificate expiry independently so a failed renewal cannot remain invisible.

TLS still needs correct DNS and authentication

TLS encrypts a connection; it does not establish a good sending reputation. The server hostname should resolve to its public IP, and the IP’s PTR record should resolve back to that hostname. Inventory every website, CRM, helpdesk and SaaS platform that sends as the business domain. Configure SPF to cover authorised senders, sign with DKIM, and publish DMARC so receivers can evaluate alignment with the visible From: domain.

Test the external path before closing the change

Validate the effective configuration first, then test each exposed service from outside the server’s network. Using -servername checks the hostname clients actually present:

postfix check
postconf -n
doveconf -n
openssl s_client -starttls smtp -connect mail.example.com:25 -servername mail.example.com
openssl s_client -starttls smtp -connect mail.example.com:587 -servername mail.example.com
openssl s_client -connect mail.example.com:993 -servername mail.example.com
sudo journalctl -u postfix -u dovecot -f

Finally, send inbound and outbound test messages, inspect the queue and confirm that a real mail client can authenticate. Keep the previous configuration available for rollback until those tests pass.

If this server supports customer communication or operational alerts, the valuable work is not merely enabling TLS. It is separating policies correctly, automating renewal, aligning DNS and leaving the team with a testable operating procedure. Contact Greg if you want the configuration reviewed or the change planned and implemented safely.

Related on GrN.dk

  • Sending Mail from a Linux Server with Postfix: A Reliable, Relay-First Setup
  • CodeIgniter Login and Password Resets: Practical Security for Live Projects
  • Sending Mail with Drupal: Reliable Email Setup for Business Sites

Need help with this kind of work?

Discuss your mail-server setup with Greg Get in touch with Greg.

Sources

  • Postfix TLS Support
  • Dovecot CE SSL/TLS configuration
  • Certbot User Guide
  • Email sender guidelines — Gmail Help
Last modified
2026-08-01

Tags

  • Linux
  • Email
  • TLS
  • Postfix
  • Dovecot
  • Log in to post comments

Review Greg on Google

Greg Nowak Google Reviews

 

Illustrated infographic summarizing: Prompt Caches Have Write Costs Now—Audit What Your Workflow Reuses
Prompt Caches Have Write Costs Now—Audit What Your Workflow Reuses
2026-08-10

GPT-5.6 makes cache writes billable. See how to spot wasted writes, stabilise prompt prefixes, place breakpoints and measure whether caching pays.

Illustrated infographic summarizing: The AI Crawler in Your Logs May Be Wearing a Borrowed Name
The AI Crawler in Your Logs May Be Wearing a Borrowed Name
2026-08-09

A User-Agent is a claim, not proof. See how to verify AI crawler traffic before it shapes reporting, robots.txt decisions, or WAF exceptions.

Illustrated infographic summarizing: AI Agents Need a Spending Brake, Not Just a Billing Dashboard
AI Agents Need a Spending Brake, Not Just a Billing Dashboard
2026-08-08

AI agent costs can climb inside a single workflow. Runtime budgets, loop detection, outcome metrics, and safe handoffs keep that spending under control.

Illustrated infographic summarizing: Drupal 12 Slipped to December. Drupal 10 Still Runs Out of Road
Drupal 12 Slipped to December. Drupal 10 Still Runs Out of Road
2026-08-07

Drupal 12 arrives as Drupal 10 support ends in December 2026. Moving to Drupal 11.3+ first keeps two mandatory upgrades manageable.

Illustrated infographic summarizing: EU OpenAI Residency Is a Migration Project, Not a Dashboard Toggle
EU OpenAI Residency Is a Migration Project, Not a Dashboard Toggle
2026-08-05

An EU-resident OpenAI API setup needs a new project, regional routing, dependency and state migration, compatibility testing, and clear governance evidence.

Illustrated infographic summarizing: AI Images Need a Chain of Custody, Not Just a Disclosure Label
AI Images Need a Chain of Custody, Not Just a Disclosure Label
2026-08-04

AI image labels are only the endpoint. Learn how to test C2PA credentials through editing, CMS, CDN and agency handoffs while preserving evidence.

Illustrated infographic summarizing: MCP Just Went Stateless: Audit the Integrations Behind Your AI Tools
MCP Just Went Stateless: Audit the Integrations Behind Your AI Tools
2026-08-03

The 28 July 2026 MCP release removes protocol sessions and changes discovery, tasks, caching, OAuth and tracing. A practical guide to auditing the move.

Illustrated infographic summarizing: SEO Trends for 2026: What Actually Changed Since 2024
SEO Trends for 2026: What Actually Changed Since 2024
2026-08-03

A practical guide to what changed in SEO between 2024 and 2026, from AI and multimodal search to Core Web Vitals, privacy and local visibility.

Illustrated infographic summarizing: INP and Green SEO Share a Backlog: Cut the Work Every Visit Repeats
INP and Green SEO Share a Backlog: Cut the Work Every Visit Repeats
2026-08-03

INP and sustainable web work often expose the same waste. Use field data, profiling, caching and performance budgets to build one practical backlog.

Illustrated infographic summarizing: AI crawler policy now has verbs: separate search, RAG, and training
AI crawler policy now has verbs: separate search, RAG, and training
2026-08-02

AI crawler rules now need separate decisions for search, RAG, and training, backed by practical testing across robots.txt, CDNs, WAFs, and CMS controls.

More articles
RSS feed

Footer

  • All articles
  • Contact

GrN.dk web platforms, web optimization, data analysis, data handling and logistics.