Location: PHPKode > projects > phpCAMALEO > common/fun2inc/validate_email.inc
<?php
require($_SESSION[common].'fun2inc/mailserver_checks.inc');

if(!function_exists('validate_email'))
{
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	# Validate an email
	#
	function validate_email($email)
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	{
		if($email=='') { return(BuildErrorString(1011)); }
		if($_SESSION[misc][MAILSRV]=='none') { return('valid'); }
		global $feedback, $error_msg;
		#
		#	Replace unwanted chars
		#
		$tmp=eregi_replace("\n",'',strtolower($email));
		$tmp=eregi_replace(" +",'',$tmp);
		#
		#	Do the simple validation
		#
		$ereg_string="^[\'+\\./0-9A-Z^_\`a-z{|}~\-]+@[a-zA-Z0-9_\-]+(\.[a-zA-Z0-9_\-]+){1,5}$";
		if(!eregi($ereg_string,$tmp))
		{
			return(BuildErrorString('<b>'.$email.'</b>: '.$error_msg[1017]));
		}
		else
		{
			#	Check the domain
			#
			list($username,$domain)=split('@',$tmp);
			$host_ip=gethostbyname('www.'.$domain);
			if($host_ip=='www.'.$domain)	{ return(BuildErrorString('<b>'.strtoupper($domain).'</b>: '.$error_msg[1018])); }
			#
			$feedback=mailserver_checks($domain,$email,false);
			if($feedback!='valid' && $feedback!='not checked') { return($feedback); } else { return('valid'); }
		}
	}
}
?>
Return current item: phpCAMALEO