Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

Email services limitation

the mail() function

Moderators: macek, egami, gesf

Email services limitation

Postby flexluther » Sat Jan 21, 2012 4:31 pm

Could someone please help me with something that I am trying to figure out?
I currently have this:

if(substr($email, -14) == "mailinator.com" ||substr($email, -14) == "MAILINATOR.COM" ||substr($email, -14) == "Mailinator.com"){
die("&result=invalid_email&load=ok");
}

This works perfect in preventing people signing up using mailinator but I am trying to include other mail services like yopmail. Could someone please point me in the right direction how to exclude yopmail?

This is driving me nuts! lol
flexluther
New php-forum User
New php-forum User
 
Posts: 3
Joined: Sat Jan 21, 2012 4:27 pm

Re: Email services limitation

Postby TheProdigyGuy » Sat Jan 21, 2012 4:57 pm

Should work)

Code: Select all
<?php
$blacklisted=array('mailinator.com','yopmail.com'); // blacklisted!

$email=strtolower('admin@yopmail.com'); // it is for test.Should come from your script.

if(!filter_var($email,FILTER_VALIDATE_EMAIL)) die('Incorrect mail Format!');
$domain=substr($email,(strrpos($email,'@',0)+1),strlen($email));
echo $domain;


foreach($blacklisted as $items)
{
if(stristr($domain,$items)) die('You Are not allowed to use this webmail domain!');
}
unset($items);
echo 'You are Welcome!';

?>
TheProdigyGuy
New php-forum User
New php-forum User
 
Posts: 215
Joined: Wed Dec 07, 2011 5:25 pm

Re: Email services limitation

Postby TheProdigyGuy » Sat Jan 21, 2012 5:24 pm

You can also use it something like this:(function)


Code: Select all
    <?php
    $email='admin@yopmail.com'; // it is for test.Should come from your script.(user input)
   
    blacklistedmailservices($email); //calling out function
   
   
    //#BELOW OUR FUNCTION WHICH WILL CHECK IS IT BLACKLISTED? #
    function blacklistedmailservices(&$dummy='')
    {
    global $email;
    $blacklisted=array('mailinator.com','yopmail.com'); // blacklisted!

    if(!filter_var($email,FILTER_VALIDATE_EMAIL)) die('Incorrect mail Format!');
    $domain=substr($email,(strrpos($email,'@',0)+1),strlen($email));
    //echo $domain;


    foreach($blacklisted as $items)
    {
    if(stristr($domain,$items)) die('&result=invalid_email&load=ok');
    }
    unset($items);
   
    }
   //############ END OF blacklistedmailservices FUNCTION #########
    ?>
TheProdigyGuy
New php-forum User
New php-forum User
 
Posts: 215
Joined: Wed Dec 07, 2011 5:25 pm

Re: Email services limitation

Postby flexluther » Sat Jan 21, 2012 5:32 pm

Thank you :) I will give that a try and let you know how it went.
flexluther
New php-forum User
New php-forum User
 
Posts: 3
Joined: Sat Jan 21, 2012 4:27 pm

Re: Email services limitation

Postby flexluther » Mon Jan 23, 2012 10:24 am

OK I couldn't get that to work but after some playing around I did this and it works!!

if($email == "" || preg_match('/^[A-Z0-9_-][A-Z0-9._-]*@([A-Z0-9][A-Z0-9-]*\.)+[A-Z]{2,6}$/i',$email) ==0 || strpos($email,"mailinator.com") || strpos($email,"MAILINATOR.COM") || strpos($email,"bofthew.com") || strpos($email,"thankyou2010.com") || strpos($email,"THANKYOU2010.COM") || strpos($email,"jetable.org") || strpos($email,"yopmail.com") || strpos($email,"YOPMAIL.COM") || strpos($email,"pjjkp.com") || strpos($email,"PJJKP.COM") || strpos($email,"spambox.us") || strpos($email,"lhsdv.com") || strpos($email,"@mail.com") || strpos($email,"guerrillamailblock.com") || strpos($email,"dispostable.com") || strpos($email,"g.mintemail.com") || strpos($email,"mailcatch.com") || strpos($email,"fakeinbox.com" || strpos($email,"@MAIL.COM"))){
die("&result=invalid_email&load=ok");
} else {
if ($email == preg_match('/^[A-Z0-9_-][A-Z0-9._-]*@owlpic.com/i')) {
die("&result=invalid_email2&load=ok");
}
}
flexluther
New php-forum User
New php-forum User
 
Posts: 3
Joined: Sat Jan 21, 2012 4:27 pm

Re: Email services limitation

Postby TheProdigyGuy » Mon Jan 23, 2012 5:06 pm

Not sure why it didn't works for you(It works for me like charm)

But: Using your own way: Client can bypass that 'filtering' easily:
it is enought in this case:
COMES FROM CLIENT==>$email='somemail@MaIlInAtOr.coM';
And thats all it is bypassed!

Do strtolower() or strtoupper() before validating it:

Code: Select all
<?php


$email=strtolower($email);// Will deny from bypass
//$email=strtolower('admin@mailInAtor.com');// Will deny from bypassing
if($email == "" || preg_match('/^[A-Z0-9_-][A-Z0-9._-]*@([A-Z0-9][A-Z0-9-]*\.)+[A-Z]{2,6}$/i',$email) ==0 || strpos($email,"mailinator.com") || strpos($email,"MAILINATOR.COM") || strpos($email,"bofthew.com") || strpos($email,"thankyou2010.com") || strpos($email,"THANKYOU2010.COM") || strpos($email,"jetable.org") || strpos($email,"yopmail.com") || strpos($email,"YOPMAIL.COM") || strpos($email,"pjjkp.com") || strpos($email,"PJJKP.COM") || strpos($email,"spambox.us") || strpos($email,"lhsdv.com") || strpos($email,"@mail.com") || strpos($email,"guerrillamailblock.com") || strpos($email,"dispostable.com") || strpos($email,"g.mintemail.com") || strpos($email,"mailcatch.com") || strpos($email,"fakeinbox.com" || strpos($email,"@MAIL.COM"))){
die("&result=invalid_email&load=ok");
} else {
if ($email == preg_match('/^[A-Z0-9_-][A-Z0-9._-]*@owlpic.com/i',$email)) {
die("&result=invalid_email2&load=ok");
}
}


?>



Anyway,Glad to see you figured it out!)
TheProdigyGuy
New php-forum User
New php-forum User
 
Posts: 215
Joined: Wed Dec 07, 2011 5:25 pm


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 0 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron