Phases Posted February 15, 2007 Share Posted February 15, 2007 Test for Manuel Lemos's PHP E-mail validation class <?php require("email_validation.php"); $validator=new email_validation_class; /* * If you are running under Windows or any other platform that does not * have enabled the MX resolution function GetMXRR() , you need to * include code that emulates that function so the class knows which * SMTP server it should connect to verify if the specified address is * valid. */ if(!function_exists("GetMXRR")) { /* * If possible specify in this array the address of at least on local * DNS that may be queried from your network. */ $_NAMESERVERS=array(); include("getmxrr.php"); } /* * If GetMXRR function is available but it is not functional, you may * use a replacement function. */ /* else { $_NAMESERVERS=array(); if(count($_NAMESERVERS)==0) Unset($_NAMESERVERS); include("rrcompat.php"); $validator->getmxrr="_getmxrr"; } */ /* how many seconds to wait before each attempt to connect to the destination e-mail server */ $validator->timeout=10; /* how many seconds to wait for data exchanged with the server. set to a non zero value if the data timeout will be different than the connection timeout. */ $validator->data_timeout=0; /* user part of the e-mail address of the sending user ([email protected] in this example) */ $validator->localuser="info"; /* domain part of the e-mail address of the sending user */ $validator->localhost="phpclasses.org"; /* Set to 1 if you want to output of the dialog with the destination mail server */ $validator->debug=1; /* Set to 1 if you want the debug output to be formatted to be displayed properly in a HTML page. */ $validator->html_debug=1; /* When it is not possible to resolve the e-mail address of destination server (MX record) eventually because the domain is invalid, this class tries to resolve the domain address (A record). If it fails, usually the resolver library assumes that could be because the specified domain is just the subdomain part. So, it appends the local default domain and tries to resolve the resulting domain. It may happen that the local DNS has an * for the A record, so any sub-domain is resolved to some local IP address. This prevents the class from figuring if the specified e-mail address domain is valid. To avoid this problem, just specify in this variable the local address that the resolver library would return with gethostbyname() function for invalid global domains that would be confused with valid local domains. Here it can be either the domain name or its IP address. */ $validator->exclude_address=""; if(IsSet($_GET["email"])) $email=$_GET["email"]; if(IsSet($email) && strcmp($email,"")) { if(($result=$validator->ValidateEmailBox($email))<0) echo " It was not possible to determine if $email is a valid deliverable e-mail box address.\n"; else echo " $email is ".($result ? "" : "not ")."a valid deliverable e-mail box address.\n"; } else { $port=(strcmp($port=getenv("SERVER_PORT"),"") ? intval($port) : 80); $site="http://".(strcmp($site=getenv("SERVER_NAME"),"") ? $site : "localhost").($port==80 ? "" : ":".$port).GetEnv("REQUEST_URI"); echo "Access this page using a URL like: $site?email=[email protected] \n"; } ?> Quote Link to comment Share on other sites More sharing options...
Phases Posted February 15, 2007 Author Share Posted February 15, 2007 Re: Awesome 1st step to email validation. Of course - I must be fair and say that I did not write this... I just thought it was worth sharing. Quote Link to comment Share on other sites More sharing options...
CraigF Posted February 15, 2007 Share Posted February 15, 2007 Re: Awesome 1st step to email validation. you should write were they should but put into and what files! Quote Link to comment Share on other sites More sharing options...
Phases Posted February 15, 2007 Author Share Posted February 15, 2007 Re: Awesome 1st step to email validation. That's interesting... I don't have DNS.php either. Sorry - I felt the file descriptions at the top were sufficient for what to do... First File: email_validation.php - This is the actual class that checks the email address - put this in your class folder. Second File: getmxrr.php - you probably won't need this one, I didn't. I is a replacement function if your PHP was compiled w/o getmxrr. If you need it, I'd suggest putting in your class folder as well. Third File: Test file - you can name it whatever you want. Also - as far as simple... I made a staff_email.php file that allows staff to see (obviously, re-used my IP Banning code... LOL) <? session_start(); include "sglobals.php"; if($ir[user_level] != 2){ echo "You are not an administrator and should not be trying to access this file. Logged."; stafflog_add("<font color=\"red\">Attempted to access email ban (not admin)</font>"); $h->endpage(); exit; } if(!isset($_POST[submit])){ banform(); $h->endpage(); exit; } else { ban_ip(); $h->endpage(); exit; } function ban_ip(){ global $db, $ir, $h; $reason = mysql_real_escape_string($_POST[ban_reason]); $address = mysql_real_escape_string($_POST[address]); $db->query("INSERT INTO blacklist_domains (bl_text, bl_reason, bl_date, bl_userid) VALUES ('$address', '$reason', unix_timestamp(), $ir[userid])"); echo "You have banned the domain: $address for $reason. This has been logged."; stafflog_add("Banned domain: $address"); echo "<hr>"; banform(); $h->endpage(); exit; } function banform(){ global $db, $ir, $h; $ipq = "SELECT * FROM blacklist_domains WHERE bl_text = '$_GET[address]'"; $ips = $db->query($ipq); if($db->num_rows($ips) > 0){ echo "<font color=\"red\">This email is already banned\"</font> "; } require("class/email_validation.php"); $validator=new email_validation_class; if(!function_exists("GetMXRR")) { $_NAMESERVERS=array(); include("getmxrr.php"); } $validator->timeout=10; $validator->data_timeout=0; $validator->localuser="mailtestacct"; $validator->localhost="alteredfuture.com"; $validator->debug=0; $validator->html_debug=1; $validator->exclude_address=""; if(IsSet($_GET["address"])) $email=$_GET["address"]; if(IsSet($email) && strcmp($email,"")) { if(($result=$validator->ValidateEmailBox($email))<0) echo "<font color=\"yellow\">It was not possible to determine if [b]$email[/b] is a valid address.</font>\n"; else echo "<font color=\"yellow\">[b]$email[/b] is ".($result ? "" : "<font color=\"red\">not</font> ")."a valid address.</font>\n"; } else { $port=(strcmp($port=getenv("SERVER_PORT"),"") ? intval($port) : 80); $site="http://".(strcmp($site=getenv("SERVER_NAME"),"") ? $site : "localhost").($port==80 ? "" : ":".$port).GetEnv("REQUEST_URI"); echo "<H2>Access this page using a URL like: $site?email=<A HREF=\"[email protected]\"><TT>[email protected]</TT></A></H2>\n"; } list($username, $domain)=split('@',$_GET[address]); echo ' <form action="staff_email.php" method="post"> <table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2"> </td> </tr> <tr> <td>Domain to blacklist:</td> <td><input name="address" type="text" size="30" maxlength="30" value="'.$domain.'"></td> </tr> <tr> <td>Reason:</td> <td><input name="ban_reason" type="text" size="50" maxlength="50"></td> </tr> <tr> <td colspan="2"><div align="right"> <input type="submit" name="submit" value="Submit"> </div></td> </tr> </table> </form> } ?> When the administrator clicks on the users email address from the admin panel - they see one of the following: Quote Link to comment Share on other sites More sharing options...
oxidati0n Posted May 13, 2007 Share Posted May 13, 2007 Re: Awesome 1st step to email validation. nice but its a bit too long for just a email validation. Quote Link to comment Share on other sites More sharing options...
stryker Posted May 15, 2007 Share Posted May 15, 2007 Re: Awesome 1st step to email validation. and space Quote Link to comment Share on other sites More sharing options...
stryker Posted May 16, 2007 Share Posted May 16, 2007 Re: Awesome 1st step to email validation. well depends on if you encode or not, encoding gonna add at leat 50kb to size Quote Link to comment Share on other sites More sharing options...
iseeyou94056 Posted June 22, 2007 Share Posted June 22, 2007 Re: Awesome 1st step to email validation. is thair a way that someone could re-post this with where the files go Quote Link to comment Share on other sites More sharing options...
$$ ?????? $$ Posted July 5, 2007 Share Posted July 5, 2007 Re: Awesome 1st step to email validation. its a nice modification some people may think it it really good but i think it isn't because 100 game users about 70 will have msn and the others that dont they will not be able to join which isnm't really fair and some dont like joining games that have email validation. :| Quote Link to comment Share on other sites More sharing options...
Decepti0n Posted July 5, 2007 Share Posted July 5, 2007 Re: Awesome 1st step to email validation. I just use a disposable email address, and since when is hotmail the only email provider Quote Link to comment Share on other sites More sharing options...
$$ ?????? $$ Posted July 5, 2007 Share Posted July 5, 2007 Re: Awesome 1st step to email validation. well theirs a load of others liek yahoo and that aswell but some people dont have none of that you know so how will they join ..?? Quote Link to comment Share on other sites More sharing options...
Jesse60905 Posted July 6, 2007 Share Posted July 6, 2007 Re: Awesome 1st step to email validation. ! sec... www.yahoo.com www.msn.com www.aol.com That's just off the top of my head but they are all free. Quote Link to comment Share on other sites More sharing options...
Jake Posted July 13, 2007 Share Posted July 13, 2007 Re: Awesome 1st step to email validation. Surely an easier and much quicker way to do this is to send an email to the user with a link/code? Quote Link to comment Share on other sites More sharing options...
twist_killer Posted July 14, 2007 Share Posted July 14, 2007 Re: Awesome 1st step to email validation. ! sec... www.yahoo.com www.msn.com www.aol.com That's just off the top of my head but they are all free. Gmail :-P Quote Link to comment Share on other sites More sharing options...
Jesse60905 Posted July 20, 2007 Share Posted July 20, 2007 Re: Awesome 1st step to email validation. Yeah lol. Quote Link to comment Share on other sites More sharing options...
nypthamine Posted November 19, 2007 Share Posted November 19, 2007 Re: Awesome 1st step to email validation. i think im having problem...i had register but my mail dont have response from my web..what happen acctually?after reg i can log in..lolz...do some one know wht? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.