| [ Index ] |
PHP Cross Reference of MantisBT |
[Summary view] [Print] [Text view]
1 <?php 2 # This program is distributed under the terms and conditions of the LGPL 3 # See the README and LICENSE files for details 4 5 /** 6 * Disposable Email Checker - a static php based check for spam emails 7 * @copyright Copyright (C) 2007-2008 Victor Boctor 8 * @link http://www.mantisbt.org/ 9 * @link http://www.futureware.biz/disposable 10 * @version 1.1.0-git - Release Date: 13-Apr-2008 11 * @package DisposableEmail 12 */ 13 14 /** 15 * A class that checks an email address and provides some facts about whether 16 * it is a disposable, free web mail, etc. The data that is used to make 17 * such decision is static as part of the class implementation, hence 18 * avoiding a round trip to a remote service. This makes the class much 19 * more efficient in scenarios where performance is an issue. 20 * @package DisposableEmail 21 */ 22 class DisposableEmailChecker 23 { 24 static $forwarding_domains_array = array( 25 '1chuan.com', 26 '1zhuan.com', 27 '4warding.com', 28 '4warding.net', 29 '4warding.org', 30 'despammed.com', 31 'e4ward.com', 32 'emailias.com', 33 'fakemailz.com', 34 'gishpuppy.com', 35 'hidemail.de', 36 'imstations.com', 37 'jetable.org', 38 'kasmail.com', 39 'mailfreeonline.com', 40 'mailmoat.com', 41 'mailnull.com', 42 'mailshell.com', 43 'mailzilla.com', 44 'mintemail.com', 45 'netzidiot.de', 46 'punkass.com', 47 'safersignup.de', 48 'shiftmail.com', 49 'sneakemail.com', 50 'spambob.net', 51 'spamex.com', 52 'spamgourmet.com', 53 'spamhole.com', 54 'spammotel.com', 55 'spamslicer.com', 56 'spamtrail.com', 57 'temporaryforwarding.com', 58 'trashmail.net', 59 'xemaps.com', 60 'xmaily.com' 61 ); 62 63 static $trash_domains_array = array( 64 '10minutemail.com', 65 '675hosting.com', 66 '675hosting.net', 67 '675hosting.org', 68 '75hosting.com', 69 '75hosting.net', 70 '75hosting.org', 71 'ajaxapp.net', 72 'amiri.net', 73 'amiriindustries.com', 74 'anonymail.dk', 75 'bugmenot.com', 76 'bspamfree.org', 77 'buyusedlibrarybooks.org', 78 'discardmail.com', 79 'dodgeit.com', 80 'dontsendmespam.de', 81 'emaildienst.de', 82 'emailmiser.com', 83 'etranquil.com', 84 'etranquil.net', 85 'etranquil.org', 86 'fastacura.com', 87 'fastchevy.com', 88 'fastchrysler.com', 89 'fastkawasaki.com', 90 'fastmazda.com', 91 'fastmitsubishi.com', 92 'fastnissan.com', 93 'fastsubaru.com', 94 'fastsuzuki.com', 95 'fasttoyota.com', 96 'fastyamaha.com', 97 'getonemail.com', 98 'gowikibooks.com', 99 'gowikicampus.com', 100 'gowikicars.com', 101 'gowikifilms.com', 102 'gowikigames.com', 103 'gowikimusic.com', 104 'gowikinetwork.com', 105 'gowikitravel.com', 106 'gowikitv.com', 107 'haltospam.com', 108 'ichimail.com', 109 'ipoo.org', 110 'killmail.net', 111 'klassmaster.com', 112 'link2mail.net', 113 'lortemail.dk', 114 'maileater.com', 115 'mailin8r.com', 116 'mailinator.com', 117 'mailinator.net', 118 'mailinator2.com', 119 'mailquack.com', 120 'mailslapping.com', 121 'myspaceinc.com', 122 'myspaceinc.net', 123 'myspaceinc.org', 124 'myspacepimpedup.com', 125 'mytrashmail.com', 126 'no-spam.hu', 127 'nobulk.com', 128 'noclickemail.com', 129 'nospamfor.us', 130 'oneoffemail.com', 131 'oneoffmail.com', 132 'oopi.org', 133 'ourklips.com', 134 'pimpedupmyspace.com', 135 'pookmail.com', 136 'rejectmail.com', 137 'recyclemail.dk', 138 'rklips.com', 139 'shortmail.net', 140 'sofort-mail.de', 141 'sogetthis.com', 142 'spam.la', 143 'spamavert.com', 144 'spambob.com', 145 'spambog.com', 146 'spamfree24.com', 147 'spamfree24.net', 148 'spamfree24.org', 149 'spaml.com', 150 'tempemail.net', 151 'tempinbox.com', 152 'temporaryinbox.com', 153 'trash-mail.de', 154 'trashdevil.com', 155 'trashdevil.de', 156 'trashmail.net', 157 'turual.com', 158 'twinmail.de', 159 'upliftnow.com', 160 'uplipht.com', 161 'viditag.com', 162 'viewcastmedia.com', 163 'viewcastmedia.net', 164 'viewcastmedia.org', 165 'wetrainbayarea.com', 166 'wetrainbayarea.org', 167 'whopy.com', 168 'willselfdestruct.com', 169 'wilemail.com', 170 'xagloo.com', 171 'yopmail.com' 172 ); 173 174 static $shredder_domains_array = array( 175 'spambob.org' 176 ); 177 178 static $time_bound_domains_array = array( 179 '10minutemail.com', 180 'bugmenot.com', 181 'buyusedlibrarybooks.org', 182 'despam.it', 183 'dontreg.com', 184 'dotmsg.com', 185 'emailto.de', 186 'getonemail.com', 187 'guerrillamail.com', 188 'guerrillamail.net', 189 'haltospam.com', 190 'jetable.com', 191 'jetable.net', 192 'jetable.org', 193 'kasmail.com', 194 'link2mail.net', 195 'lovemeleaveme.com', 196 'mailexpire.com', 197 'mailzilla.com', 198 'mintemail.com', 199 'no-spam.hu', 200 'noclickemail.com', 201 'oneoffemail.com', 202 'oopi.org', 203 'pookmail.com', 204 'shortmail.net', 205 'spambox.us', 206 'spamfree24.com', 207 'spamfree24.org', 208 'spamfree24.net', 209 'spamhole.com', 210 'spamify.com', 211 'tempemail.net', 212 'tempinbox.com', 213 'temporaryinbox.com', 214 'temporarily.de', 215 'trashdevil.com', 216 'trashdevil.de', 217 'trashmail.net', 218 'walala.org', 219 'wh4f.org', 220 'yopmail.com' 221 ); 222 223 static $open_domains_array = array( 224 'aim.com', 225 'aol.com', 226 'bk.ru', 227 'blu.it', 228 'BTinternet.com', 229 'caramail.com', 230 'exclusivemail.co.za', 231 'executive.co.za', 232 'free.fr', 233 'freemail.hu', 234 'gawab.com', 235 'gmail.com', 236 'gmx.at', 237 'gmx.de', 238 'gmx.net', 239 'googlemail.com', 240 'hanmail.net', 241 'homemail.co.za', 242 'hotmail.co.uk', 243 'hotmail.com', 244 'hotmail.de', 245 'hotmail.fr', 246 'hotmail.it', 247 'inbox.ru', 248 'iol.it', 249 'libero.it', 250 'list.ru', 251 'lycos.at', 252 'lycos.co.uk', 253 'lycos.de', 254 'lycos.es', 255 'lycos.it', 256 'lycos.nl', 257 'magicmail.co.za', 258 'mail.com', 259 'mail.ru', 260 'mailbox.co.za', 261 'msn.co.uk', 262 'msn.com', 263 'netscape.com', 264 'netscape.net', 265 'o2.pl', 266 'pancakemail.com', 267 'ravemail.co.za', 268 'rediffmail.com', 269 'starmail.co.za', 270 'talk21.com', 271 'thecricket.co.za', 272 'thegolf.co.za', 273 'thepub.co.za', 274 'therugby.co.za', 275 'ukr.net', 276 'yahoo.ca', 277 'yahoo.co.in', 278 'yahoo.co.jp', 279 'yahoo.co.uk', 280 'yahoo.com', 281 'yahoo.com.ar', 282 'yahoo.com.asia', 283 'yahoo.com.au', 284 'yahoo.com.br', 285 'yahoo.com.cn', 286 'yahoo.com.es', 287 'yahoo.com.hk', 288 'yahoo.com.malaysia', 289 'yahoo.com.mx', 290 'yahoo.com.ph', 291 'yahoo.com.sg', 292 'yahoo.com.tw', 293 'yahoo.com.vn', 294 'yahoo.de', 295 'yahoo.dk', 296 'yahoo.es', 297 'yahoo.fr', 298 'yahoo.gr', 299 'yahoo.ie', 300 'yahoo.it', 301 'yahoo.se', 302 'web.de', 303 'webmail.co.za', 304 'websurfer.co.za', 305 'workmail.co.za' 306 ); 307 308 /** 309 * Determines if the email address is disposable. 310 * 311 * @param $p_email The email address to validate. 312 * @returns true: disposable, false: non-disposable. 313 */ 314 public static function is_disposable_email( $p_email ) { 315 return ( 316 DisposableEmailChecker::is_forwarding_email( $p_email ) || 317 DisposableEmailChecker::is_trash_email( $p_email ) || 318 DisposableEmailChecker::is_time_bound_email( $p_email ) || 319 DisposableEmailChecker::is_shredder_email( $p_email ) ); 320 } 321 322 /** 323 * Determines if the email address is disposable email that forwards to 324 * users' email address. This is one of the best kind of disposable 325 * addresses since emails end up in the user's inbox unless the user 326 * cancel the address. 327 * 328 * @param $p_email The email address to check. 329 * @returns true: disposable forwarding, false: otherwise. 330 */ 331 public static function is_forwarding_email( $p_email ) { 332 $t_domain = DisposableEmailChecker::_get_domain_from_address( $p_email ); 333 return in_array( $t_domain, DisposableEmailChecker::$forwarding_domains_array ); 334 } 335 336 /** 337 * Determines if the email address is trash email that doesn't forward to 338 * user's email address. This kind of address can be checked using a 339 * web page and no password is required for such check. Hence, data sent 340 * to such address is not protected. Typically users use these addresses 341 * to signup for a service, and then they never check it again. 342 * 343 * @param $p_email The email address to check. 344 * @returns true: disposable trash mail, false: otherwise. 345 */ 346 public static function is_trash_email( $p_email ) { 347 $t_domain = DisposableEmailChecker::_get_domain_from_address( $p_email ); 348 return in_array( $t_domain, DisposableEmailChecker::$trash_domains_array ); 349 } 350 351 /** 352 * Determines if the email address is a shredder email address. Shredder 353 * email address delete all received emails without forwarding them or 354 * making them available for a user to check. 355 * 356 * @param $p_email The email address to check. 357 * @returns true: shredded disposable email, false: otherwise. 358 */ 359 public static function is_shredder_email( $p_email ) { 360 $t_domain = DisposableEmailChecker::_get_domain_from_address( $p_email ); 361 return in_array( $t_domain, DisposableEmailChecker::$shredder_domains_array ); 362 } 363 364 /** 365 * Determines if the email address is time bound, these are the disposable 366 * addresses that auto expire after a pre-configured time. For example, 367 * 10 minutes, 1 hour, 2 hours, 1 day, 1 month, etc. These address can 368 * also be trash emails or forwarding emails. 369 * 370 * @param $p_email The email address to check. 371 * @returns true: time bound disposable email, false: otherwise. 372 */ 373 public static function is_time_bound_email( $p_email ) { 374 $t_domain = DisposableEmailChecker::_get_domain_from_address( $p_email ); 375 return in_array( $t_domain, DisposableEmailChecker::$time_bound_domains_array ); 376 } 377 378 /** 379 * See is_open_domain() for details. 380 */ 381 function is_free_email( $p_email ) { 382 return $this->is_open_email( $p_email ); 383 } 384 385 /** 386 * Determines if the email address is an email address in an open domain. These are 387 * addresses that users can sign up for, typically free. They then has to login to 388 * these address to get the emails. These are not considered to be 389 * disposable emails, however, if the application is providing a free 390 * trial for an expensive server, then users can signup for more accounts 391 * to get further trials. 392 * 393 * If applications are to block these addresses, it is important to be aware 394 * that some users use open webmail as their primary email and that such 395 * service providers include hotmail, gmail, and yahoo. 396 * 397 * @param $p_email The email address to check. 398 * @returns true: open domain email, false: otherwise. 399 */ 400 public static function is_open_email( $p_email ) { 401 $t_domain = DisposableEmailChecker::_get_domain_from_address( $p_email ); 402 return in_array( $t_domain, DisposableEmailChecker::$open_domains_array ); 403 } 404 405 /** 406 * A debugging function that takes in an email address and dumps out the 407 * details for such email. 408 * 409 * @param $p_email The email address to echo results for. This must be a 410 * safe script (i.e. no javascript, etc). 411 */ 412 function echo_results( $p_email ) { 413 echo 'email address = ', htmlspecialchars( $p_email ), '<br />'; 414 echo 'is_disposable_email = ', DisposableEmailChecker::is_disposable_email( $p_email ), '<br />'; 415 echo 'is_forwarding_email = ', DisposableEmailChecker::is_forwarding_email( $p_email ), '<br />'; 416 echo 'is_trash_email = ', DisposableEmailChecker::is_trash_email( $p_email ), '<br />'; 417 echo 'is_time_bound_email = ', DisposableEmailChecker::is_time_bound_email( $p_email ), '<br />'; 418 echo 'is_shredder_email = ', DisposableEmailChecker::is_shredder_email( $p_email ), '<br />'; 419 echo 'is_free_email = ', DisposableEmailChecker::is_free_email( $p_email ), '<br />'; 420 } 421 422 /** 423 * A debugging function that outputs some statistics about the number of domains in 424 * each category. 425 */ 426 function echo_stats() { 427 echo 'Forwarding Domains: ' . count( DisposableEmailChecker::$forwarding_domains_array ) . '<br />'; 428 echo 'Free Domains: ' . count( DisposableEmailChecker::$open_domains_array ) . '<br />'; 429 echo 'Shredded Domains: ' . count( DisposableEmailChecker::$shredder_domains_array ) . '<br />'; 430 echo 'Time Bound: ' . count( DisposableEmailChecker::$time_bound_domains_array ) . '<br />'; 431 echo 'Trash Domains: ' . count( DisposableEmailChecker::$trash_domains_array ) . '<br />'; 432 } 433 434 // 435 // Private functions, shouldn't be called from outside the class 436 // 437 438 /** 439 * A helper function that takes in an email address and returns a lower case 440 * domain. 441 * 442 * @param $p_email The email address to extra the domain from. 443 * @returns The lower case domain or empty string if email not valid. 444 */ 445 private static function _get_domain_from_address( $p_email ) { 446 $t_domain_pos = strpos( $p_email, '@' ); 447 if ( $t_domain_pos === false ) { 448 return ''; 449 } 450 451 return strtolower( substr( $p_email, $t_domain_pos + 1 ) ); 452 } 453 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jul 28 15:48:31 2011 | Cross-referenced by PHPXref 0.7 |