I have what I hope is a fairly normal home postfix setup. I fetch POP3 mail using fetchmail, which passes on to postfix via /usr/sbin/sendmail. In postfix's master.cf I added a spamassassin
service, and set -o content_filter=spamassassin
on the smtp service.
I want postfix to use spamassassin to filter the incoming mail, but for some reason it's not doing that.
It is filtering outgoing mail, though: Here are some samples from /var/log/mail.log:
Receiving (not filtered, why not?):
Sep 19 01:40:05 fitpc postfix/local[31480]: 062CC2CE070F: to=<mailandy@example.com>, orig_to=<mailandy>, relay=local, delay=0.43, delays=0.24/0.05/0/0.14, dsn=2.0.0, status=sent (delivered to command: procmail -a "$EXTENSION")
Sending (filtered, don't really need this):
Sep 19 01:07:16 fitpc postfix/pipe[31190]: 8CB252CE070E: to=<andybalaam@example.com>, relay=spamassassin, delay=0.48, delays=0.1/0.05/0/0.33, dsn=2.0.0, status=sent (delivered via spamassassin service)
Could it be because fetchmail is using /usr/sbin/sendmail rather than talking to postfix over the network? Or does sendmail go over the network too?
Config:
$ postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
message_size_limit = 0
mydestination = fitpc, localhost.localdomain, localhost, ubuntu-desktop, server-vm, example.com
myhostname = fitpc
mynetworks = 127.0.0.0/8 10.0.1.0/24 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = example.com
notify_classes = resource,software,bounce,2bounce,delay,policy,protocol
readme_directory = no
recipient_delimiter = +
relayhost = relay.plus.net
smtp_tls_note_starttls_offer = yes
smtp_tls_security_level = may
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
smtpd_relay_restrictions = permit_sasl_authenticated,defer_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain =
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_tls_auth_only = no
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_security_level = may
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
$ postconf -M
2025 inet n - - - - smtpd -o content_filter=spamassassin
pickup unix n - - 60 1 pickup
cleanup unix n - - - 0 cleanup
qmgr unix n - n 300 1 qmgr
tlsmgr unix - - - 1000? 1 tlsmgr
rewrite unix - - - - - trivial-rewrite
bounce unix - - - - 0 bounce
defer unix - - - - 0 bounce
trace unix - - - - 0 bounce
verify unix - - - - 1 verify
flush unix n - - 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - - - - smtp
relay unix - - - - - smtp -o smtp_fallback_relay=
showq unix n - - - - showq
error unix - - - - - error
retry unix - - - - - error
discard unix - - - - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - - - - lmtp
anvil unix - - - - 1 anvil
scache unix - - - - 1 scache
maildrop unix - n n - - pipe flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
uucp unix - n n - - pipe flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
ifmail unix - n n - - pipe flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp unix - n n - - pipe flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix - n n - 2 pipe flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman unix - n n - - pipe flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py ${nexthop} ${user}
spamassassin unix - n n - - pipe -v user=debian-spamd argv=/usr/bin/spamc -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}
Best Answer
Of course, as soon as I wrote this up I had an idea, and got it working.
The problem is not in the postfix or spamassassin config at all, but in the fetchmail config.
I had this in my .fetchmailrc:
but because this uses
/usr/sbin/sendmail
, it doesn't put the mail into postfix's queue, but delivers it directly (it turns out), so it bypasses the spam filters. What I needed was:(Because my postfix listens on port 2025. If it listened on port 25, we wouldn't need the smpthost line at all.)