How to: Test Spam Assassin’s Spam Score¶
The qmail-inject
tool can be used to send messages back into the mail queue. This can
be useful if there is an issue with spam, where messages that appear to be scored correctly
are not being sent to the correct directory.
To Test SpamAssasin’s Scoring¶
Log in to the server at the CLI as root, either via SSH or from the terminal
At the CLI, navigate to the email user’s mail directory. It is found at
/home/{unixuser}/var/{domain.com}/mail/{mailuser}/Maildir
, replacing{unixuser}
,{domain.com}
, and{mailuser}
, with the corresponding informationcd /home/{unixuser}/var/{domain.com}/mail/{mailuser}/Maildir
Navigate to the mail folder the message that will be used for testing resides. There are three possible mail folders:
New: Where new messages that have yet to be seen in the inbox are located
Cur: Messages in the inbox, which have been already been viewed or addressed
Tmp: Messages that have yet to be sent to the inbox
.Spam: Where messages marked as spam are sent
Messages that can be used for testing will most likely be located in either
cur
, ornew
.Make a copy of the message that will be used for testing and move that copy to
/tmp
or/root
as a backupcp 1645131655.M949881P22057V0000000000010301I0000000000518F00.server.com,S=2621 /tmp/1645131655.M949881P22057V0000000000010301I0000000000518F00.server.com,S=2621
Using a text editor, open the original message. The following example uses the Vim text editor:
vim 1645131655.M949881P22057V0000000000010301I0000000000518F00.server.com,S=2621
Remove all X-Spam related headers. They are located at the top of the file. For example:
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server.com X-Spam-Level: * X-Spam-Status: No, score=1.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2
Save the file and exit the text editor
Inject the message back into the mail queue using the
qmail-inject
tool. This will process and score the message again/var/qmail/bin/qmail-inject < 1645131655.M949881P22057V0000000000010301I0000000000518F00.server.com,S=2621