spamassassin: Spam Filtering

The spamassassin utility is used to manage the Spamassassin spam filter through CLI. By using this utility, you can perform the following tasks:

  • enabling/disabling server-wide spam filtering
  • setting the criteria for automatic labeling of incoming messages as spam
  • enabling/disabling use of mail-name specific spam filtering criteria
  • adding mail messages to the Spamassassin's black and white lists
  • marking mail subjects as spam
  • deleting spam automatically
  • inserting custom text into spam message subject lines automatically

Usage
spamassassin <command> [<mail_name>] [
<option_1> [<param>]
[<option_2> [<param>]]
... [<option_N> [<param>]]
]

Example

The following command enables Spamassassin filter on the mail account JDoe@example.com, enables the use of mail name-specific Spamassassin filter settings, sets the minimum score for marking email messages as spam to 3 and enables deleting spam messages automatically from the mailbox:

plesk bin spamassassin --update JDoe@example.com -status true -personal-conf true -reject-spam true -hits 3

Commands
Command Parameter Description Example

--update or -u

<mail_name>

Updates the Spamassassin spam filter settings on a Plesk mail account.

To set the minimum score for marking email messages as spam and deleting them automatically for JDoe@example.com to 3:

plesk bin spamassassin --update JDoe@example.com -hits 3 -reject-spam true

or

plesk bin spamassassin -u JDoe@example.com -hits 3 -reject-spam true

--update-server

 

Updates the Spamassassin spam filter settings on the Plesk server.

To set the minimum score for marking email messages as spam for the Plesk server to 5:

plesk bin spamassassin --update-server -hits 5

--info or -i

<mail_name>

Displays the Spamassassin spam filter settings of a Plesk mail account.

To view the Spamassassin spam filter settings of JDoe@example.com:

plesk bin spamassassin --info JDoe@example.com

or

plesk bin spamassassin -i JDoe@example.com

--info-server

 

Displays the Spamassassin spam filter settings of the Plesk server.

To view the Spamassassin spam filter settings for the Plesk server:

plesk bin spamassassin --info-server

--help or -h

 

Displays help on the use of this utility.

To view the help info on the use of the spamassassin utility:

plesk bin spamassassin --help

Options
Option Parameter Description Example

-status

true|false

Enables/Disables the Spamassassin filter.

To enable the Spamassassin filter on the mail account JDoe@example.com:

plesk bin spamassassin -u JDoe@example.com -status true

To disable the Spamassassin filter on the Plesk server:

./spamassassin --update-server -status false

-personal-conf

true|false

Enables/Disables using mail name-specific (rather than server- wide) antispam filter settings for a mail account.

To enable using mail name-specific Spamassassin filter settings on JDoe@example.com:

plesk bin spamassassin -u JDoe@example.com -personal-conf true

-hits

<number>

Specifies the minimum score for a mail message to be marked as spam.

To set the minimum score for marking mail messages as spam for JDoe@example.com to 3:

plesk bin spamassassin --update JDoe@example.com -hits 3

-max-mail-size

<number>B|K|M|G|T

Specifies e-mail message size. All messages that exceed the specified size are not processed by spam filter.

To set the spam filter for JohnDoe@example.com to skip messages larger than 5 megabytes:

plesk bin spamassassin --update JohnDoe@example.com -max-mail-size 5M

-action

del|mark|move

Specifies how to deal with e-mail messages that are considered as spam:

  • del - removes messages
  • mark - marks them as spam according to defined settings
  • move - moves them the directory called Spam.

To enable deleting spam messages automatically for JDoe@example.com:

plesk bin spamassassin --update JDoe@example.com -action del

-max-proc

1|2|3|4|5

Specifies the maximum number of simultaneously running spamd processes on server.

To set the maximum number of simultaneously running spamd processes on server to 4:

plesk bin spamassassin --update-server -max-proc 4

-modify-subj

true|false

Enables/Disables subject lines automatic modification for messages marked as spam.

To enable subject lines automatic modification for spam messages and to specify the text to be inserted in the beginning of the subject line to "***SPAM*** Score: _SCORE_ :" on JDoe@example.com:

plesk bin spamassassin -u JDoe@example.com -modify-subj true -modify-subj-text "***SPAM*** Score: _SCORE_ :"

-modify-subj-text

<string>

Specifies the text to be inserted in the beginning of a subject line for messages marked as spam.

Type _SCORE_ to include the message's spam score in the message subject line.

-reject-spam

true|false

Enables/Disables deleting spam messages automatically.

To enable deleting spam messages automatically for JDoe@example.com:

plesk bin spamassassin --update JDoe@example.com -reject-spam true

-blacklist

add|del|enable|disable>:<pattern1>[,<pattern2>,[…]]

Adds/Deletes mail patterns to/from the Spamassassin black list; enables/disables email patterns in the Spamassassin black list.

 

The enable and disable parameters are used only with the --update command.

To add e-mail patterns *jane@example.com and ???Doe@*.example.net to the Spamassassin's black list for JDoe@example.com:

plesk bin spamassassin --update JDoe@example.com -blacklist add:*jane@example.com,???user@*.example.net

-whitelist

add|del|enable|disable>:<pattern1>[,<pattern2>,[…]]

Adds email patterns to or deletes them from the Spamassassin white list. Enables or disables email patterns in the Spamassassin white list.

The enable and disable parameters are used only with the --update command.

To add e-mail patterns *jane@example.com to the Spamassassin's white list of the server:

plesk bin spamassassin --update-server -whitelist add:*jane@example.com

* Non-ASCII characters are not allowed on the left of the @ sign in the e-mail pattern. E-mail patterns can include the "*" and "?" wildcard characters (for example, *@domain.com, user?@*.com). Non-ASCII parts of domain names must not contain wildcard characters.

 

Leave your feedback on this topic here

If you have questions or need support, please visit the Plesk forum or contact your hosting provider.
The comments below are for feedback on the documentation only. No timely answers or help will be provided.