Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 18-05-2009
Member
 
Join Date: Feb 2009
Posts: 64
PHP mail verification system

I want to create a verification email system for a registration website. For this, I am looking forward to use PHP code. Also, need to design PHP Mailer in order to handle all the send mails. Can anyone provide necessary guidelines on this....Any ideas will be appreciated.....
thanks
Reply With Quote
  #2  
Old 18-05-2009
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: PHP mail verification system

You need to develop E-mail verification system when you want to make sure that the e-mail addresses entered by your visitors are valid.

This CGI script (when used with a form) will e-mail your users a random ID link that must be clicked to activate their account. You need to insert this code into one of your current scripts where you need to ensure everything is valid.

Download the Script
Reply With Quote
  #3  
Old 18-05-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: PHP mail verification system

You can use PHP’s fsockopen() function in order to find out whether an email domain is really in use. This is used to open domain socket connections over the Internet. This serves our purpose since we might try opening a socket connection to the mail server identified with the given domain. If the socket connection is successfully opened, then the supplied domain is currently in use.

The format for fsockopen() is the following:

int fsockopen ( string hostname, int port [, int errno [, string errstr [, float timeout]]]);

The function, when used for Internet domains, will open a TCP socket connection to the provided host name on the supplied port, and return a file pointer corresponding to that host. If the call fails, it will return false, and if the optional errno and errstr arguments are present, they will be set to indicate the actual system level error that occurred while performing the call. The optional timeout parameter can be used to set a timeout in seconds for the connect system call.

To open a socket connection on port 25 (the default port for SMPT servers) to the given domain for a user’s email address,

If(!fsockopen($domain,25,$errno,$errstr,30)) {
return false;
}


Here we’re trying to open a socket connection to the provided domain on port 25, setting a timeout of 30 seconds for the connection.

Here’s the checkEmail() function with the new enhancements:

Code:
function checkEmail($email) {
 // checks proper syntax
 if(preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9\._-] +)+$/" , $email)) {
  // gets domain name
  list($username,$domain)=split('@',$email);
  // checks for if MX records in the DNS
  if(!checkdnsrr($domain, 'MX')) {
   return false;
  }
  // attempts a socket connection to mail server
  if(!fsockopen($domain,25,$errno,$errstr,30)) {
   return false;
  }
  return true;
 }
 return false;
}
And the code to call the function is listed as follows:

Code:
$email = trim($_POST['email']);   
if(!checkEmail($email)) {  
echo 'Invalid email address!';
}
else {
 echo 'Email address is valid';
}

step-by-step explanation:
once the email address is passed to the function, it is first validated to make sure it matches the regular expression. If the validation is successful, then the address is divided to obtain the email domain.

Then, the function checks whether the domain is real, looking for MX records in the DNS. Again, if the records are found, the next step is to open a socket connection for that domain on port 25, to determine whether the given domain is in use. If the connection is successful, we’re pretty sure that the email address corresponds to a real domain, which is currently in use, and the user name is potentially valid.
Any checking process that returns false, will evaluate the function as false too, terminating it, therefore indicating that the supplied email address is not valid.
Reply With Quote
  #4  
Old 18-05-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: PHP mail verification system

Keep the following points in mind before developing Mail Verification System using PHP :

On the registration, first validate the email address using a regular expression to check whether it is in a proper format and also check whether the domain is actually valid.

If developing on a Windows Server, use a custom CheckDnsrr function. All works great with the exception that for domains like hotmail, yahoo, etc either I get a timeout on fsockopen or that it is unable to connect to that domain.
Note - domains which are tested that do not work with the script are hotmail.com,yahoo.com,otenet.gr,gmail.com while on most other domain names like forthenet.gr,dstavros.net,methodico.gr,gmail.net works on it.

Since you are developing a verification system for sending to that email address, a verification code (which is the second part of the verification system) is required to make this work.

If you remove this validation code and it's not validating that domain then PHPmailer should send the email properly. But then again emails are not delivered to hotmail, yahoo or some other popular domains while on others it really works well...
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "PHP mail verification system"
Thread Thread Starter Forum Replies Last Post
Opera 11 looses mail after System Crash Irshaad Technology & Internet 5 12-01-2011 07:45 AM
Mac Mail Operating System 10.6.4 Or Mobileme Being Used With Hotmail Aniela Operating Systems 5 19-12-2010 10:25 PM
WinXP System Verification Error in STREAM.SYS WDM driver error 23b SinguIar XP Hardware 4 28-08-2010 08:30 AM
Mailman List System does not send mail Adikavi Technology & Internet 6 16-06-2010 09:56 AM
System.Web.Mail In Asp.Net Adrina_g Software Development 6 03-02-2010 04:07 PM


All times are GMT +5.5. The time now is 03:38 PM.