Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to get Sendmail to speak LMTP to GNU Mailman3

Sendmail and Mailman3 - Solving the LMTP problem

Current versions of Sendmail can speak LMTP to local processes, but how to make that happen seems poorly documented. When trying to get it to talk to GNU Mailman3 recently, I found next to no documentation, and a lot of people asking how to do it, so I'm leaving this here in the hopes that it helps someone.

This document shows a simplified example of how I did it on my Ubuntu 20.04 system, at least in terms of Sendmail configuration. While I'm using a "lists" subdomain, that seems entirely optional with this technique.

virtusertable

test@lists.example.com  %1%3@lists.example.com.private
@lists.example.com      error:5.1.1:550 User unknown

While this isn't a complete set of aliases for a Mailman mailing list, it does show how to create them. "%1%3" on right becomes the original user part of the recipient address, including the + and everything after it for things like bounce and confirmation replies. The .private TLD is officially reserved for private use, and seemed like the safest choice.

It is possible to make this even simpler, creating a catch-all alias and sending everything for the lists subdomain to Mailman, but defining individual aliases shifts the load of rejecting email to addresses that don't exist back to Sendmail, where it honestly belongs.

mailertable

lists.example.com.private      mm3lmtp:[localhost]

This basically takes the rewritten recipient domain from above, which doesn't actually resolve to anything, and directs it to the custom mailer defined below.

sendmail.mc

MAILER_DEFINITIONS
Mmm3lmtp,   P=[IPC], F=PSXmnz9, S=EnvFromSMTP/HdrFromSMTP,
                R=EnvToMM3, E=\r\n, L=1024,
                A=TCP $h 8024

LOCAL_RULESETS
SEnvToMM3
R$+                     $: $>EnvToSMTP $1
R$+ < @ lists . example . com . private > $*   $: $1 < @ lists . example . com . > $2

These additions define the custom mailer used in mailertable. The port number can be whatever you want to use in your installation. The EnvToMM3 rule adds on to Sendmail's default SMTP envelope recipient rewriting, removing the .private TLD that was added in virtusertable in the process of forwarding email to the LMTP server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment