xref: /web-php/include/email-validation.inc (revision 11081310)
1<?php
2
3// Try to remove anti-SPAM bits
4function clean_AntiSPAM($email)
5{
6    $remove_spam = "![-_]?(NO|I[-_]?HATE|DELETE|REMOVE)[-_]?(THIS)?(ME|SPAM)?[-_]?!i";
7    return preg_replace($remove_spam, "", trim($email));
8}
9
10// Try to check that this email address is valid
11function is_emailable_address($email)
12{
13    $email = filter_var($email, FILTER_VALIDATE_EMAIL);
14    // No email, no validation
15    if (!$email) {
16        return false;
17    }
18
19    $host = substr($email, strrpos($email, '@') + 1);
20    // addresses from our mailing-list servers
21    $host_regex = "!(lists\.php\.net|chek[^.*]\.com)!i";
22    if (preg_match($host_regex, $host)) {
23        return false;
24    }
25
26    // When no MX-Entry can be found it's for sure not a valid email-address.
27    if (getmxrr($host, $return_values) === false) {
28        return false;
29    }
30
31    return true;
32}
33
34/**
35 * Basic blacklisting.
36 * Add email addresses, domains, or partial-match patterns
37 * to $mosquitoes array to blacklist.
38 * CAUTION: Be sure anything you add here won't partially
39 * match legitimate email addresses!  For example:
40 *     spamsend
41 * .... will match:
42 *     real_person@thisispamsendoftheweb.example.com
43 */
44function blacklisted($email) {
45    $mosquitoes = [
46        'saradhaaa@gmail.com',
47        'mg-tuzi@yahoo.com.cn',
48        'bitlifesciences',
49        'bitconferences',
50        'grandeurhk',
51        'legaladvantagellc',
52        'sanath7285',
53        'omicsgroup',
54        '@sina.com',
55        'omicsonline',
56        'bit-ibio',
57        'evabrianparker',
58        'bitpetrobio',
59        'cogzidel',
60        'vaccinecon',
61        'bit-ica',
62        'geki@live.cl',
63        'wcd-bit',
64        'bit-pepcon',
65        'proformative.com',
66        'bitcongress',
67        'medifest@gmail.com',
68        '@sina.cn',
69        'wcc-congress',
70        'albanezi',
71        'supercoderarticle',
72        'somebody@hotmail.com',
73        'bit-cloudcon',
74        'eclinicalcentral',
75        'iddst.com',
76        'achromicpoint.com',
77        'wcgg-bit',
78        '@163.com',
79        'a-hassani2011@live.fr',
80        'analytix-congress',
81        'nexus-irc',
82        'bramyao23',
83        'dbmall27@gmail.com',
84        'robinsonm750@gmail.com',
85        'enu.kz',
86        'isim-congress',
87        '.*cmcb.*',
88        'molmedcon',
89        'agbtinternational',
90        'biosensors',
91        'conferenceseries.net',
92        'wirelesscommunication',
93        'clinicalpharmacy',
94        'antibiotics',
95        'globaleconomics',
96        'sandeepsingh.torrent117232@gmail.com',
97        'herbals',
98        'europsychiatrysummit',
99        'antibodies',
100        'graduatecentral',
101        'a@a.com',
102        '@insightconferences.com',
103        '@conferenceseries.com',
104    ];
105    foreach ($mosquitoes as $m) {
106        if (preg_match('/' . preg_quote($m, '/') . '/i',$email)) return true;
107    }
108}
109