Fetchmail “mda” option makes emails bypass the spamassassin filter in postfix

I have spent several months with no spam filtering in my postfix+dovecote+spamassassin+fetchmail+procmail setup, and no idea why. I had spamassassin enabled and working when I piped emails into it manually, and I had lines like this in my postfix master.cf:

# Listen on port 2025, not 25, and filter with the spamassassin service
2025      inet  n       -       -       -       -       smtpd
	-o content_filter=spamassassin
# ...

# Definition of the spamassassin service: pipe to spamc, then sendmail
spamassassin unix -     n       n       -       -       pipe
	user=spamd argv=/usr/bin/spamc -x -e    
	/usr/sbin/sendmail -oi -f ${sender} ${recipient}

But no matter what I did, I saw no spamassassin headers in my emails, and no mention of using it in the logs. Frustratingly, it was filtering perfectly on outgoing mail, which I really don’t need…

Today I worked out what the problem was – nothing to do with postfix or spamassassin config, but to do with my .fetchmailrc.

Because I was running on a non-standard port, and also because I had tried not allowing unencrypted connections to postfix even from localhost, I was using telling fetchmail to deliver with /usr/sbin/sendmail, instead of allowing it to connect to postfix on port 25 as it normally does. So my .fetchmailrc contained:

poll example.com with proto POP3
    user 'x' there with password 'y' is 'z' here
    mda "/usr/sbin/sendmail  -i  -f %F -- %T"

It turns out this completely bypasses all the filters, and delivers the mail immediately. So, what I needed was the syntax to connect on a non-standard port, which looks like:

poll example.com with proto POP3
    user 'x' there with password 'y' is 'z' here
    smtphost localhost/2025

(If your postfix listens on port 25, you don’t need the smtphost line at all.)

And now my email is being filtered for spam, and put into a Junk folder by procmail.

Leave a Reply

Your email address will not be published. Required fields are marked *

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