Some postfix notes
Posted by jpluimers on 2020/10/15
Postfix has documentation on primary MX and secondary MX, but not on tertiary MX.
If the primary MX is down, you have a series of secondary MX and tertiary MX that configured the same way, MX DNS priority for primary, the series of secondary MX and tertiary MX have increasing numbers, and the primary MX goes down, then senders can get “too many hops” as secondary and tertiary MX are looping.
I had a hard time finding a good and easy solution as these queries do not return many meaningful results:
Here are some links that helped getting this solved:
- [WayBack] Postfix Frequently Asked Questions: What does “Error: too many hops” mean?
Short answer: this message means that mail is probably looping. If you see this after you turned on Postfix content filtering, then you have made a mistake that causes mail to be filtered repeatedly. This is cured by appropriate use of content_filter=, header_checks=, and body_checks=.
Long answer: the message has too many
Received:
message headers. A received header is added whenever Postfix (or any MTA) receives a message. A large number ofReceived:
message headers is an indication that mail is looping around.Side comment: email uses the opposite of the technique that is used to avoid IP forwarding loops. With IP, the sender sets a TTL (time to live) field in the IP header. The field is decremented by each router. When the TTL reaches zero the packet is discarded and an ICMP error message is returned to the sender.
- [WayBack] Error: too many hops (in reply to end of DATA command) · Issue #713 · mail-in-a-box/mailinabox · GitHub
In case you or anyone else was/is wondering about the
mydestination = localhost
thing, the reason it has to be set to just localhost is because MIAB uses Postfix’s “virtual domain hosting” (http://www.postfix.org/VIRTUAL_README.html) support. Per the documentation formydestination
at http://www.postfix.org/postconf.5.html#mydestination:Do not specify the names of virtual domains – those domains are specified elsewhere. See VIRTUAL_README for more information.
(in the context of MIAB every domain is a virtual domain).
In my case a series of these:
Received: from mwgp.xs4all.nl (mwgp.xs4all.nl [80.101.239.92]) by fiber24315337242.heldenvannu.net (Postfix) with ESMTP id 26395200FE for <jeroen@pluimers.com>; Fri, 29 Jun 2018 11:01:02 +0200 (CEST) Received: from fiber24315337242.heldenvannu.net (unknown [37.153.243.246]) by mwgp.xs4all.nl (Postfix) with ESMTP id 077A5E937 for <jeroen@pluimers.com>; Fri, 29 Jun 2018 11:01:02 +0200 (CEST)
Specifying the transport will likely help me solve this problem:
- postfix tell which mx host to use – Google Search
- [WayBack] How do I configure postfix to deliver mail for specified domains to another host, and deliver the rest using MX records – Server Fault
- [WayBack] postfix – Relay host based on destination MX record – Server Fault
- [WayBack] Use different SMTP Server for specific Email Address in Postfix Relay
This all came down to editing /etc/postfix/transport
adding lines for each relayed domain like this one:
example.org smtp:[mx-a-record.example.org]
Lines like it direct to use the smtp
transport and use a specific host (normally, the relay
transport is being used).
After this:
# postmap /etc/postfix/transport
# rcpostfix reload
I choose not to configure [WayBack] Postfix Configuration Parameters: relay_recipient_maps
, but might if I had an automated way of replicating lists of valid (and invalid) users.
Another option was confirmed at [WayBack] Software-update: Postfix 3.4.0 / 3.3.3 / 3.2.8 / 3.1.11 / 3.0.15 – Computer – Downloads – Tweakers by [WayBack] menocchio. Thanks!
Dat is volgens mij eenvoudig op te lossen met relay_transport of transport_maps. Zie ook: Postfix transport table format.
Daarmee dwing je de secondary servers de mail altijd af te willen leveren bij de primary server (en dus niet bij een andere secondary). En als de primary niet online is, dan wacht ie netjes tot dat wel het geval is :-)
Bijvoorbeeld:
relay_transport = smtp:[primarymx.domain.tld]
Likely relevant: [WayBack] The Book of Postfix
Maybe relevant in the future:
- postfix limit relay to hosts – Google Search
- [WayBack] debian – Remote Postfix server for email relaying multiple domains – Server Fault
- [WayBack] mysql – Postfix — mail forwarding loop – Server Fault
- [WayBack] How can I get postfix to send mail to different relay hosts? – Server Fault
- Source: postfix secondary – Google Search
- [WayBack] MX Backup – Postfix Email Server | samhobbs.co.uk
- Source: “loops back to myself” postfix mx – Google Search
- On using
mydestination
- [WayBack] smtp – mail loops back to myself | postfix – Server Fault
- [WayBack] Postfix – mail for example.com loops back to myself
- [WayBack] Postfix mail for domain.com loops back to myself Error and Solution – nixCraft
- [WayBack] Mail delivery to an external domain fails: mail loops back to myself – Plesk Help Center
- [WayBack] *solved* Postfix ‘mail for domain.com loops back to myself’ | Plesk Forum
- On using
- [WayBack] Postfix Basic Configuration:
relay_domains
andrelayhost
- [WayBack] Postfix Configuration Parameters: relay_domains
- [WayBack] Postfix Configuration Parameters: relayhost which information is overruled with relay_transport, sender_dependent_default_transport_maps, default_transport, sender_dependent_relayhost_maps and with the transport(5)
- [WayBack] Postfix Small/Home Office Hints and Tips
- [WayBack] Postfix Standard Configuration Examples
- especialy [WayBack] Postfix Standard Configuration Examples: Postfix email firewall/gateway
- but basically all of it:
The first part of this document presents standard configurations that each solve one specific problem.- Postfix on a stand-alone Internet host
- Postfix on a null client
- Postfix on a local network
- Postfix email firewall/gateway
The second part of this document presents additional configurations for hosts in specific environments.
- “postfix” “tertiary mx” – Google Search and “postfix” “relayhost” “tertiary mx” – Google Search
- [WayBack] How to configure Postfix relayhost (smarthost) to send eMail using an external smptd – nixCraft
- [WayBack] Postfix: Backup MX | SecOPS / SysOp blog which makes me need to research if these are still relevant:
- ___
Found on my hunt for the above:
- [WayBack] postfix secondary mx relay only to primary mx – Google Search
- [WayBack] postfix relay bounce – Google Search
- [WayBack] [SOLVED] postfix ‘status=bounced’ unable to send email to a domain
- [WayBack] Postfix Transport Maps – Diverting Mail Traffic | nooblet.org
Create a file named
transport
in /etc/postfix and add the following text,gmail.com smtp:smtp.yourisp.com:25
googlemail.com smtp:smtp.yourisp.com:25Remember to swap “smtp.yourisp.com” for the address of your ISP’s smtp relay server.
Now we need to compile this file using the postmap command,
postmap /etc/postfix/transport
Edit /etc/postfix/main.cf and add this line at the bottom,
transport_maps = hash:/etc/postfix/transport
Restart postfix and you should find all mail addressed to @gmail.com or @googlemail.com will be redirected to your smtp relay.
- [WayBack] Postfix Transport Maps – Diverting Mail Traffic | nooblet.org
- [WayBack] Postfix Performance Tuning: Tuning the number of simultaneous deliveries
- [WayBack] Postfix Configuration Parameters: fallback_relay fallback_relay (default: empty)
Optional list of relay hosts for SMTP destinations that can’t be found or that are unreachable. With Postfix 2.3 this parameter is renamed to smtp_fallback_relay.
- [WayBack] Postfix Configuration Parameters: smtp_fallback_relay smtp_fallback_relay (default: $fallback_relay)
Optional list of relay hosts for SMTP destinations that can’t be found or that are unreachable. With Postfix 2.2 and earlier this parameter is called fallback_relay.
- [WayBack] [SOLVED] postfix ‘status=bounced’ unable to send email to a domain
Try not to make typo’s: [WayBack] postfix appears not finding MX records or host names from DNS
Interesting thought, but not sure how smart SPAM bots are now: [Archive.is] Spam relaying through secondary MX… – Google Groups
To archive this:
- Rename from
- To
- Then save in Archive.is
–jeroen
Leave a Reply