I use Postfix in my machine (linux).
When i send a mail to a local user with telnet localhost 25 in command line, my mail is parsed by a content-filter (for example: spamassassin) => no problem.
But when i send a mail to the same local user with mail command (or sendmail command or mail php), my mail is sent but not parsed by the content-filter => so why ?
Why my mail is not parsed by a content-filter when i use the mail command ?
My postfix configuration is very basic :
postconf -n :
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
html_directory = /usr/share/doc/postfix/html
inet_interfaces = all
mailbox_size_limit = 0
mydestination = localhost.localdomain, localhost, localhost.localdomain, localhost
myhostname = localhost
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
recipient_delimiter = +
relayhost =
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
postconf -M :
smtp inet n - n - - smtpd -o content_filter=spamassassin
pickup fifo n - - 60 1 pickup
cleanup unix n - - - 0 cleanup
qmgr fifo 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
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 user=mail argv=/usr/bin/spamc -u ${user} -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}
I repeat my problem : when i use telnet localhost 25 to send a mail to a local user (guest), spamassassin parse the mail, and syslog displays :
Feb 4 15:05:42 localhost postfix/smtpd[3919]: connect from localhost[::1]
Feb 4 15:05:50 localhost postfix/smtpd[3919]: EBC2460DBF: client=localhost[::1]
Feb 4 15:05:59 localhost postfix/cleanup[3922]: EBC2460DBF: message-id=<20150204140550.EBC2460DBF@localhost>
Feb 4 15:05:59 localhost postfix/qmgr[3883]: EBC2460DBF: from=<guest@localhost.localdomain>, size=342, nrcpt=1 (queue active)
Feb 4 15:05:59 localhost spamd[18634]: spamd: connection from localhost [127.0.0.1] at port 48540
Feb 4 15:05:59 localhost spamd[18634]: spamd: processing message <20150204140550.EBC2460DBF@localhost> for guest:122
Feb 4 15:06:08 localhost spamd[18634]: spamd: clean message (0.2/5.0) for guest:122 in 9.1 seconds, 296 bytes.
Feb 4 15:06:08 localhost spamd[18634]: spamd: result: . 0 - ALL_TRUSTED,MISSING_HEADERS scantime=9.1,size=296,user=guest,uid=122,required_score=5.0,rhost=localhost,raddr=127.0.0.1,rport=48540,mid=<20150204140550.EBC2460DBF@localhost>,autolearn=ham
Feb 4 15:06:08 localhost spamd[18632]: prefork: child states: II
Feb 4 15:06:08 localhost postfix/pickup[3881]: 6844560FDB: uid=8 from=<guest@localhost.localdomain>
Feb 4 15:06:08 localhost postfix/pipe[3923]: EBC2460DBF: to=<guest@localhost.localdomain>, orig_to=<guest>, relay=spamassassin, delay=22, delays=12/0.01/0/9.2, dsn=2.0.0, status=sent (delivered via spamassassin service)
Feb 4 15:06:08 localhost postfix/qmgr[3883]: EBC2460DBF: removed
Feb 4 15:06:08 localhost postfix/cleanup[3922]: 6844560FDB: message-id=<20150204140550.EBC2460DBF@localhost>
Feb 4 15:06:08 localhost postfix/qmgr[3883]: 6844560FDB: from=<guest@localhost.localdomain>, size=656, nrcpt=1 (queue active)
Feb 4 15:06:08 localhost postfix/local[3928]: 6844560FDB: to=<guest@localhost.localdomain>, relay=local, delay=0.18, delays=0.12/0.01/0/0.05, dsn=2.0.0, status=sent (delivered to mailbox)
Feb 4 15:06:08 localhost postfix/qmgr[3883]: 6844560FDB: removed
=> no problem.
But if i use just the mail command :
echo "test" | mail -s "test" guest
, the mail is sent, but spamassassin has not parsed the mail because syslog displays this :
Feb 4 15:09:36 localhost postfix/pickup[3881]: B6C1960DC0: uid=1000 from=<guest>
Feb 4 15:09:36 localhost postfix/cleanup[3956]: B6C1960DC0: message-id=<20150204140936.B6C1960DC0@localhost>
Feb 4 15:09:36 localhost postfix/qmgr[3883]: B6C1960DC0: from=<guest@localhost.localdomain>, size=339, nrcpt=1 (queue active)
Feb 4 15:09:36 localhost postfix/local[3957]: B6C1960DC0: to=<guest@localhost.localdomain>, orig_to=<guest>, relay=local, delay=0.18, delays=0.12/0/0/0.07, dsn=2.0.0, status=sent (delivered to mailbox)
Feb 4 15:09:36 localhost postfix/qmgr[3883]: B6C1960DC0: removed
An idea ?
Thanks, cordially.
Best Answer
For content filter after queue, postfix has two implementation methods, the simple and advanced content filter. You can read the explanation of both methods in its official documentation.
From your question, we can learn that you use simple content filter method. The sign is output of
postconf -M
(or the content ofmaster.cf
). It uses pipe method to pass email to spam assassin via commandPostfix official docs above also tell you the major limitation of simple content filter
So, the behavior that you see was normal.
Solution: How can I use content_filter for email submitted via mail command?
You can consider to switch your setup to use advanced content filter method. This thread on spam assassin mailing list tell you some alternative to achieve this: amavisd or spampd