Search Engine: Elastic

Article ID: 122368, created on Jul 15, 2014, last review on Dec 14, 2016

  • Applies to:
  • Plesk Automation 11.5


How to enable Spamassassin by default on mail accounts? I want that Spamassassin is enabled when I create new mail account.


Create Plesk event handler:

  1. Go to PA with link: https://<pa_management_node_ip_address>:8443/plesk/server/event-handlers/

  2. Create mail handler like below:

    Mail account created
    lowest (0)
    /root/ $NEW_MAILNAME
  3. On Management Node create a script:

    [root@pa ~]# cat /root/
    sleep 30
    /usr/local/psa/bin/spamassassin -u $1 -status true

    Additional parameters for 'spamassasin' command are:

    -action            <del|mark|move> what to do with spam mail
    -modify-subj       <true|false>    modify spam mail subject
    -modify-subj-text  <string>        modify spam mail subject text
  4. Make it executable:

    [root@pa ~]# chmod +x /root/

    Now when you create new mail account, Spamassassin will be enabled by default in mail account.

In order to enable Spamassassin for all existing mailboxes you can use the following script:


#Get the list of mailboxes registered in PA

    mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -sNe "select mail.mail_name, from mail left join domains on" | sed -E 's/[[:space:]]+/@/g' > /tmp/mailboxes_list

    #Enable spamassassin for mailboxes

    while read mailbox
    /usr/local/psa/bin/spamassassin -u $mailbox -status true
    done < /tmp/mailboxes_list

33a70544d00d562bbc5b17762c4ed2b3 e0aff7830fa22f92062ee4db78133079 caea8340e2d186a540518d08602aa065

Email subscription for changes to this article
Save as PDF