Filters for cPanel email background: I was attempting to create a filter in cPanel that would forward all addresses starting with "mj" followed by either an underscore or a year after 2020 directed at the domain "mjphd.net". instructions: The first step is to select the mailbox for the default email on the domain mjphd.net. This is done in the cPanel controls under the email heading. Select filter. It generates a complete list of all email accounts on the hosted domains. Select the email box set as the default for the mjphd.net domain. I'm a big user of email aliases. This allows me to create an email identity that I can kill should a service be compromised. As an example, I created josabank@mjphd.net when I placed an order. They lost control of their email list and the spam was rampant. To rid myself of the spam, I simply killed the alias. This works well but requires I create a new address for each site by creating the email alias in cPanel, a bit cumbersome. I moved to using wildcards. Starting an address with "mj_" and then adding something else provides an on-the-fly method for creating a throw away email. Should the service be compromised, or should I just tire of the emails, it is easy to create a filter on the server to discard the email or route it to junk. The email "mj_test@mjphd.net" doesn't resolve since there is no mailbox or alias. Email sent to that address will go to the default email for the mjphd.net domain. Selecting that email and creating a filter allows the email to go to a monitored email box. Here is how it is done:
Looking at the ([M,m][J,j][_,2])\w+@mjphd.net is useful. The square brackets define two choices, M or m, J or j, and underscore or 2. They are in parentheses indicating they are all together. The \w matches any word character and the plus sign adjacent means any number. Bringing up the rear is @mjphd.net to match. It could have been enclosed in parentheses, but they are optional. The regex test site listed below is incredibly helpful for playing around. references: cPanel docs: https://docs.cpanel.net/knowledge-base/email/how-to-configure-email-filters/ dPanel docs on global filters: https://docs.cpanel.net/cpanel/email/global-email-filters/ the Webmaster: hhttps://www.thewebmaster.com/how-to-setup-cpanel-user-level-filtering-for-email/ Jonny Fox info on RegEx: https://medium.com/factory-mind/regex-tutorial-a-simple-cheatsheet-by-examples-649dc1c3f285 GitHub cheat sheet based on above: https://gist.github.com/ahmadelgamal/d3ea09a794856a386aeb949ef7a91f4e RegEx test site: https://regexr.com/ |