In the previous article in this series, we explored the basics of configuring email for your domain using cPanel and learning how to set up spam blocking and an autoresponder. Before we leave the subject of mail, though, there are a few more useful things to learn that will allow mastery of mail on our shared server.
Forwarding Made Easy
Mail forwarding isn’t actually that hard conceptually; you’re just sending an extra copy somewhere else. Learning all the power behind that simple statement is what we’ll be doing here. First, a warning: if you happened to set up BoxTrapper to stop spam, you should not use the generalized mail forwarding capabilities detailed here for any BoxTrapper accounts, but instead use the forwarding built in to BoxTrapper itself.
Clicking on “Forwarders” allows you to add mail forwarders for either an ordinary mail account (foo@bar.com) or for an entire domain. Let’s take the domain forwarding first; this is often used when a company is initially setting up a number of websites. There won’t be enough business to justify hiring people for each support position for each separate website, so by forwarding all of a domain’s email to another domain, one entire staff (tech support, customer support, sales, etc.) can service all the websites if the same generic mailbox names are used. Mail to “sales” at any of the domains is simply forwarded to the shared sales staff at the main domain. If money is even tighter, you can even forward all the mail for an entire domain to a single address; this may not work for an extended period because that one person will be very stressed out, though!
Forwarding a single mail account gives you even more choices. The user interface lets you pick any valid address at any of your configured domains; then the fun begins. You can forward to any valid email address anywhere, or mark this account as invalid by bouncing an automatic system error back to the original sender of the email. Note that this last part is not exactly the same as marking the account invalid within the actual email subsystem (which is generally done with sendmail and beyond the scope of this article), because mail will still be delivered to the mailbox, but it should eventually cut down on mail to that account.
By clicking the Advanced Options link, you get access to even more. Forwarding to a system user lets you route the email to an account that’s defined on the shared server itself, but not an Internet-accessible address (so you can forward to “help” or “root” or “admin”, but not help@domain.com). You can discard all the email sent to that account, but it will all disappear silently and there will be no useful end result (which is why it says Not Recommended).
By far, the most open-ended thing you can do with mail is to pipe it to a program, which could be a commercial program of some sort or one that you or a programmer has written for special processing that can’t be done using any of the filters or other options available here.
Mail Filtering
That would have to be some really special processing, however, because cPanel gives you access to some very powerful processing capabilities under the title of Filtering.
Account Level Filtering is intended only for your signup account, which is generally not used for email anyway. The User Level Filters for individual mail accounts is where all the action takes place, so go there, pick one of your accounts, and then Manage Filters. You’ll get to a screen where you can define a custom filtering rule; here is the first dropdown:
As you can see, you have quite a few choices of things you can select to test in this filtering rule. But wait, there’s more:
Here are all the tests you can make against the portion of the message you selected initially, and then you can type in a string or regular expression on the next line. Not enough? Click the plus sign all the way to the right:
That’s right, you can keep adding more selection criteria, using the logical operators “or” and “and” to link them. But what can you do with it when you’re done?
Perhaps not quite anything, but pretty close! And as you might have noticed on the initial filter screen, there’s even a built-in system to help make it very easy for you to test sample messages to ensure the filter you just created works the way you expect.