Looking to set up your Plesk server to automatically move spam messages to a Spam folder for all mailboxes? Well, you can't do this through the Plesk GUI for all accounts at once, but you can achieve it via the command line interface (CLI) using SpamAssassin. Let's walk through the steps together.

What is SpamAssassin?

SpamAssassin is an open-source spam filtering software that uses a variety of mechanisms to identify and filter out unwanted email (spam). By setting it up on your Plesk server, you can enhance your email security and manage spam more effectively.

Pre-requisites

  • You must have access to Plesk and the ability to log in via SSH.
  • Ensure you have administrative privileges to install and configure software.
  • Make sure your Plesk installation is up to date.

Steps to Configure Spam Filtering

1. Log in to Plesk

Access your Plesk control panel using your admin credentials.

2. Install SpamAssassin

Navigate to:

  • Tools & Settings
  • Updates & Upgrades

Look for the SpamAssassin installation option and proceed with the installation.

3. Access Your Server via SSH

Use an SSH client to log into your Plesk server. Here’s how to do it from a terminal:

ssh username@your-server-ip

4. Configure Spam Filtering for Existing Mailboxes

Download the script that will help move spam messages to existing mailboxes:

curl -OL https://raw.githubusercontent.com/plesk/kb-scripts/master/move-mail-to-spam/existing-mailboxes.sh

Next, grant execution permission to the script:

chmod +x existing-mailboxes.sh

Now, execute the script to apply the changes:

./existing-mailboxes.sh

5. Configure Spam Filtering for Newly Created Mailboxes

To manage spam for any new mailboxes created in the future, download this script:

curl -OL https://raw.githubusercontent.com/plesk/kb-scripts/master/move-mail-to-spam/new-mailboxes.sh

Again, grant execution permission:

chmod +x new-mailboxes.sh

6. Set Up Event Handler in Plesk

Go back to your Plesk control panel:

  • Navigate to Tools & Settings
  • Select Event Manager

Now, click on Add Event Handler:

    • Select the event Mail account created.
    • Specify the path to the script in the command field:
/root/new-mailboxes.sh

Best Practices

  • Regularly monitor the spam filtering performance and adjust settings as necessary.
  • Test the setup with a few mailboxes to ensure it’s working as intended before applying it server-wide.
  • Keep your Plesk installation and scripts updated to maintain security and functionality.

Disclaimer

Always test these steps in a safe test environment first. Refer to the latest Plesk documentation for any updates or changes.

Did this answer help? 0 People found this helpful (0 Votes)