Printed/downloaded from www.mxorb.com :: Copyright © mxORB Software, All Rights Reserved
Using regular expressions it is possible to blacklist all emails from a specific domain. In the examples below, the domain we want to block is spammerdomain.com. Follow the steps below to add a blacklist filter:
^\S+@spammerdomain\.com$The regular expression ^\S+@spammerdomain\.com$ can be broken down as follows:
^ means match the start of the email address\S+ means match one or more non-whitespace characters@ means match the @ signhotmail\.com matches hotmail.com (note the backslash in front of the period - this is necessary because the period has a special meaning in regular expressions)$ matches the end of the email address. This means the only emails ending @hotmail.com will match, @hotmail.com.uk, @hotmail.com.br, etc. would not matchIf you want to filter a domain and any possible subdomains (for example: user@spammerdomain.com, user@sub1.spammerdomain.com, user@sub2.spammerdomain.com, etc) you can use the following: ^\S+@(?:\S+\.)*domain\.com$
^ means match the start of the email address\S+ means match one or more non-whitespace characters@ means match the @ sign(?:\S+\.) means match one or more non-whitespace characters followed by a period* matches the expression in brackets zero or more times, this means that an address will match if it contains zero, one or more subdomainsdomain\.com matches the required domain and you would change this as appropriate$ matches the end of the email addressDate: July 29th 2004