Make Spamassassin learn spam mails

Eoin Kim Eoin.Kim at
Tue May 2 03:14:05 UTC 2017

Hi Mark,

Thanks for your reply. So, I guess the mutt is being used as an MUA for postfix user and the inbox of postfix user would be '/var/spool/postfix/incoming' something like that? So, this concept is not intercepting the incoming emails, is it? The mails will continue flowing as usual? I have to read manuals further but if you don't mind, I'd like to know the principle of this method. Thanks a lot.


-----Original Message-----
From: MailScanner [ at] On Behalf Of Mark Sapiro
Sent: Tuesday, 2 May 2017 12:58 PM
To: mailscanner at
Subject: Re: Make Spamassassin learn spam mails

On 05/01/2017 07:13 PM, Eoin Kim wrote:
> This might sound like a stupid question but I am having trouble with 
> making SA learn spam emails. I have MailScanner and MailWatch running 
> in my work. Recently, we have received some spams. Few of them were 
> actually just delivered to receivers as a clean email. I wanted to 
> make SA learn these clean emails as a spam but it looks like I can’t do that.
> The ones I can do are the emails already regarded as spam. They 
> already have {Spam?} prefix in the subject and its status already 
> shows spam in MailWatch. Are there any ways I can achieve this? Thanks in advance.

I run SpamAssassin as "spamd" and I also have "spamc" installed. I have a few ways of reporting messages to SpamAssassin to be learned. The mail client I use when logged in to a shell (as a privileged user) on the MailScanner server is mutt. I have these macros defined in mutt:

macro index H "|spamc -u postfix -L ham\r" "Spamassassin learn as ham"
macro pager H "|spamc -u postfix -L ham\r" "Spamassassin learn as ham"
macro index S "|spamc -u postfix -L spam\r" "Spamassassin learn as spam"
macro pager S "|spamc -u postfix -L spam\r" "Spamassassin learn as spam"
macro index X "|spamc -u postfix -L forget\r" "Spamassassin forget"
macro pager X "|spamc -u postfix -L forget\r" "Spamassassin forget"

Then, if I have selected a message in mutt's index or if I am viewing the message, I can just type "H" to learn the message as ham, "S" to learn it as spam or "X" to forget it if I learned it by mistake.

Note that -u postfix is important, but it isn't necessarily "postfix".
It is the user that MailScanner runs SpamAssassin as, normally the configured "Run As User". Also note that -L requires spamd to be run with the "--allow-tell" option (see man spamc).

I also have an alias in my postfix that is effectively

Spam_Report: "|spamc -u postfix -L spam  || true"

I have found however that I needed to put this in a separate alias file with the corresponding .db (I use hashes) owned by postfix as the "-u postfix" doesn't seem to be effective for non privileged users.

Mark Sapiro <mark at>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan

MailScanner mailing list
mailscanner at

More information about the MailScanner mailing list