Postfix Too Many Hops with Spamassassin

We create open-source because we love it, and we share our finding so everyone else can benefit as well.


Postfix Too Many Hops with Spamassassin

I’ve noticed a lot of people have had an issue with the Postfix “Too Many Hops” error. I ran into the same issue, with my Postfix Spamassassin setup. Postfix is a beast, and tweaking is often needed to keep it working smooth.

In my case, this happened when the and were looping messages back and forth to each other. Since Postfix has several options which overlap, this can happen easily.

I used a common Postfix, Courier, SMTP Auth, SpamAssassin setup, and it wasn’t uncommon to use content filters. Unfortunately, the filter were set on both the inbound and outbound transfers, causing a loop. When filtering in both the, and the, then adding spamassassin, it’s easy to cause a loop between the two.

Postfix Too Many Hops with Content Filters

Commenting out the content filter in the file, is a good place to start.

#content_filter = spamassassin:[]:10025

smtp      inet  n       -       -       -       4       smtpd           -o content_filter=spamassassin
spamassassin unix -     n       n       -       -       pipe
         user=spamd argv=/usr/bin/spamc -f -e
         /usr/sbin/sendmail -oi -f ${sender} ${recipient}

When disabled, restart Postfix, and check to see if you still get the postfix too many hops error. If it does, you know where the issue lies.

So looking at the changes, you may notice the loop. This particular setup was meant to filter SMTP traffic, and then pass it to the recipient. When the inbound is set to filter as well, we end up with a continuous loop between filters, causing a “too many hops” error.

Other Cases

There are certainly other causes for this error, but relatively the same. If your case is not with the content filter, check your other listeners. Did the error come from a message being sent, or being received? Most options can be omitted in the main and master. Using trial-and-error, it won’t take long to pin down the root of the issue.

If you have run into another scenario, leave a comment letting us know, and I’ll happily share it. 👍


No Comments

Add your comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.