Servers are notorious for receiving copious amounts of spam. Even small to medium load servers have to deal with loads of it every day. The ease of setting up an e-mail account on cPanel makes this a real problem to contend with. To solve this, many users rely on the inbuilt tool called SpamAssassin which you need to enable in order for it to filter your e-mails. It's their first line of defense.
By default, SpamAssassin doesn't have a "spam" or "junk" folder. It just discards everything that's marked as spam. However, we can enable a "spam folder" into which everything that gets marked as spam gets dumped. Using this, you can check to see if there are any false positives - genuine messages which got marked as spam by accident. For example, here's a test spam message that I sent to my cPanel and viewing in the Horde webmail client interface provided by cPanel:
This works great, but there's only one problem. The folder is called "spam" (lower case instead of starting with an upper case letter). For some reason, this can really bug the hell out of you - especially since all the other folders around it are capitalized!
Getting the Location of the Spam (and other) Folders
To start with, let's look at the locations of these folders in the underlying system. On my Linux box running CentOS 7, I found the folders under:
These folders are all hidden, and we can show them using a command like:
ls -a | egrep '^\.'
On my box, here's what this brings up:
As you can see, all the folders are hidden (starting with a dot). If you want, you can delete the ".spam" folder from here after this tutorial.
Creating a New Filter for Spam
To move our spam to a new folder called "Spam", we need to create a new e-mail filter. Log into cPanel, and head down to the e-mail section and select "Email Filters" like this:
Over here, you'll be asked to select an account for which you want to create e-mail filters. Select the one you want and click on "Manage Filters"
Once inside, click "Create a New Filter"
Now to create the new filter in the "Rules" section, enter the following:
- First drop down box - select "Spam Status";
- Second drop down box - select "begins with";
- In the text box below, type "Yes" (without quotes).
Now, in the "Actions" section, do the following:
- In the drop down box, choose "Deliver to Folder";
- In the text area, type "/.Spam" (without quotes).
Here's what the rules section looks like:
If you want, you can change "/.Spam" to any other folder name like "/.Junk" or "/.Bulk" or something like that. Now that the rules have been set up, it's time to test them!
Testing the Spam Rules
The new folder won't appear immediately because it's only created when actual spam mail arrives. You can either wait for spam mail, or you can send yourself one. Fortunately, there is a standard e-mail recognized by SpamAssassin that serves as a "test dummy". You can find it here.
Basically the e-mail contains this predefined string:
This will automatically be flagged by SpamAssassin as spam. Note that you need to send it from outside your e-mail network.
When this e-mail arrives, it's marked by SpamAssassin and delivered to our folder using the rules we specified above. Here's a screenshot:
It works! Not only have we created a new spam folder with a capitalized first letter, we've also moved it up the tree so that it sits at the same level as "Inbox" and "Drafts"! This is a perfect workaround to the (sometimes) annoying and un-capitalized spam folder.