I have a Postfix installation on a single machine which is the sole final mail destination for:
- The hostname of the machine (
mail.example.org
) andlocalhost
- Mailman lists on
lists.example.org
- A number of virtual domains
The relevant settings in main.cf
are:
myhostname = mail.example.org
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = $myhostname
mydestination = localhost, $myorigin
relay_domains = $mydestination, lists.example.org
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
# Virtual domains
virtual_mailbox_base = /var/mail/vhosts
virtual_mailbox_domains = hash:/etc/postfix/virtual_domains
virtual_mailbox_maps = hash:/etc/postfix/virtual_mailboxes
virtual_alias_maps = hash:/etc/postfix/virtual_aliases
virtual_minimum_uid = 100
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
# mailman configuration
mailman_destination_recipient_limit = 1
transport_maps = hash:/etc/postfix/transport
smtpd_relay_restrictions = permit_mynetworks,
reject_invalid_hostname,
reject_unknown_sender_domain,
reject_unknown_recipient_domain,
reject_unauth_destination,
reject_unlisted_recipient,
reject_rbl_client zen.spamhaus.org,
permit
At present, mail for lists.example.org
is routed to Mailman through the following transport_maps
setting:
lists.example.org mailman:
This works, but it means that if an email is sent to an unknown list, the message is accepted by Postfix and then bounced when it is processed by Mailman. For several reasons -- particularly reducing backscatter and rejecting mail as early as possible -- I want Postfix to reject mail as soon as it sees a RCPT TO
which matches @lists.example.org
and doesn't correspond to a Mailman list.
I think I can achieve this result by creating a file containing all the Mailman list aliases and specifying this as relay_recipient_maps
in main.cf
. However, my understanding is that relay_recipient_maps
applies to relay_domains
, and I don't want $mydestination
addresses to be affected.
So my two related questions are:
- Should I remove
$mydestination
fromrelay_domains
, and if I do will my existing aliases continue to work? - If
relay_domains
is set tolists.example.org
, willrelay_recipient_maps
achieve the result I want?
Alternatively, if there's a way for Postfix to query Mailman and get a response before accepting the mail for delivery (perhaps with a before-queue filter - this is how I handle mail to SpamAssassin), that would also achieve what I want.
Thanks in advance. :-)