Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Amigo_zz

Verificar se email existe

Recommended Posts

Pessoal,Tenho um sistema de newsletter em asp+mysql. É possivel via asp verificar se um email que esta na base de dados existe na realidade para evitar enviar um email para ele?Li em alguns foruns que isso é possivel em php e cf, mas em asp, nao vi nada...Alguma ajuda?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Caro Amigo_zz,

 

Podemos fazer da seguinte maneira.

1º - Coloque o código PHP que achou , para podemos "migrar" para o ASP.

2º - Ou então, podemos criar uns "scripts" de verificação em ASP para validar os seus email´s.

 

Até!!

Compartilhar este post


Link para o post
Compartilhar em outros sites

Estes são grandinhos, mas vou passar:

 

 

Arquivo: getmxrr.php

 

<?php/* * getmxrr.php * * @(#) $Header: /home/mlemos/cvsroot/PHPlibrary/getmxrr.php,v 1.1 2002/06/21 05:33:42 mlemos Exp $ * *//* ------------------------------------------------------------------------   PHPresolver - PHP DNS resolver library				 Version 1.1   Copyright (c) 2001, 2002 Moriyoshi Koizumi <koizumi@ave.sytes.net>   All Rights Reserved.   This library is free software; you can redistribute it and/or modify it   under the terms of the GNU Lesser General Public License as published   by the Free Software Foundation; either version 2.1 of the License, or any   later version.   This library is distributed in the hope that it will be useful, but   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public   License for more details.   You should have received a copy of the GNU Lesser General Public License   along with this library; if not,   write to the Free Software Foundation, Inc.,   59 Temple Place, Suite 330, Boston, MA 02111-1307  USA  ------------------------------------------------------------------------ */	if(IsSet($_NAMESERVERS)	&& (GetType($_NAMESERVERS)!="array"	|| count($_NAMESERVERS)==0))		Unset($_NAMESERVERS);/*************************************************************************** Description  $_NAMESERVER[]	The array that contains IP addresses or domain names of name servers	used for DNS resolution.	If nothing is set before require()'ing this library, the values will	automatically prepared.  bool getmxrr( string $hostname, arrayref $mxhosts, arrayref $weight );	This function works in the same way as getmxrr(), however the	third parameter cannot be omitted. If you need no MX preference	information, please do like:		   getmxrr( 'example.com', $mxhosts, ${''} ); ------------------------------------------------------------------------- Configuration  If you are doing with win32 environments and don't set $_NAMESERVER  manually, make sure that ipconfig.exe is within the PATH.  ipconfig.exe is generally distributed with any Microsoft(R) Windows  distributions except for Windows 95. ***************************************************************************/	require_once( 'DNS.php' );	/* rewrite this path to the same as the box's configuration	   if you run scripts on *NIX platforms */	define( 'RESOLV_CONF_PATH', '/etc/resolv.conf' );	if( !isset( $_NAMESERVERS ) ) {		$_NAMESERVERS = array();		if( strncmp( PHP_OS, "WIN", 3 ) == 0 ) {			unset( $res );//			exec( 'ipconfig /all', $res );			$cnt = count( $res );			for( $i = 0; $i < $cnt; ++$i ) {				if( strpos( $res[$i], 'DNS Servers' ) !== false ) {					$_NAMESERVERS[] = substr( $res[$i], strpos( $res[$i], ': ' ) + 2 );					break;				}			}			while( $i<$cnt-1 && strpos( $res[++$i], ':' ) === false ) {				$_NAMESERVERS[] = trim( $res[$i] );			}		} elseif( file_exists( RESOLV_CONF_PATH ) ) {			$lines = file( RESOLV_CONF_PATH );			$cnt = count( $lines );			for( $i = 0; $i < $cnt; ++$i ) {				list( $dr, $val ) = split( '[ \t]', $lines[$i] );				if( $dr == 'nameserver' ) {					$_NAMESERVERS[] = rtrim( $val );				}			}			unset( $lines );		}	}	if(count($_NAMESERVERS))		$__PHPRESOLVER_RS = new DNSResolver( $_NAMESERVERS[0] );	else	{		Unset($_NAMESERVERS);		Unset($__PHPRESOLVER_RS);	}	function GetMXRR( $hostname, &$mxhosts, &$weight ) {		global $__PHPRESOLVER_RS;		if(!IsSet($__PHPRESOLVER_RS))			return(false);		$dnsname = & DNSName::newFromString( $hostname );		$answer = & $__PHPRESOLVER_RS->sendQuery(		  new DNSQuery(			new DNSRecord( $dnsname, DNS_RECORDTYPE_MX )		  )		);		if( $answer === false || $answer->rec_answer === false ) {			return false;		} else {			$i = count( $answer->rec_answer );			$mxhosts = $weight = array();			while( --$i >= 0 ) {				if( $answer->rec_answer[$i]->type == DNS_RECORDTYPE_MX ) {					$rec = &$answer->rec_answer[$i]->specific_fields;					$mxhosts[] = substr( $rec['exchange']->getCanonicalName(), 0, -1 );					$weight[] = $rec['preference'];				}			}			return true;		}	}?>

Arquivo Email_validation.php

<?php/* * email_validation.php * * @(#) $Header: /home/mlemos/cvsroot/emailvalidation/email_validation.php,v 1.23 2005/09/16 18:20:58 mlemos Exp $ * */class email_validation_class{	var $email_regular_expression="^([-!#\$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#\$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,6}\$";	var $timeout=0;	var $data_timeout=0;	var $localhost="";	var $localuser="";	var $debug=0;	var $html_debug=0;	var $exclude_address="";	var $getmxrr="GetMXRR";	var $next_token="";	var $preg;	var $last_code="";	Function Tokenize($string,$separator="")	{		if(!strcmp($separator,""))		{			$separator=$string;			$string=$this->next_token;		}		for($character=0;$character<strlen($separator);$character++)		{			if(GetType($position=strpos($string,$separator[$character]))=="integer")				$found=(IsSet($found) ? min($found,$position) : $position);		}		if(IsSet($found))		{			$this->next_token=substr($string,$found+1);			return(substr($string,0,$found));		}		else		{			$this->next_token="";			return($string);		}	}	Function OutputDebug($message)	{		$message.="\n";		if($this->html_debug)			$message=str_replace("\n","<br />\n",HtmlEntities($message));		echo $message;		flush();	}	Function GetLine($connection)	{		for($line="";;)		{			if(feof($connection))				return(0);			$line.=fgets($connection,100);			$length=strlen($line);			if($length>=2			&& substr($line,$length-2,2)=="\r\n")			{				$line=substr($line,0,$length-2);				if($this->debug)					$this->OutputDebug("S $line");				return($line);			}		}	}	Function PutLine($connection,$line)	{		if($this->debug)			$this->OutputDebug("C $line");		return(fputs($connection,"$line\r\n"));	}	Function ValidateEmailAddress($email)	{		if(IsSet($this->preg))		{			if(strlen($this->preg))				return(preg_match($this->preg,$email));		}		else		{			$this->preg=(function_exists("preg_match") ? "/".str_replace("/", "\\/", $this->email_regular_expression)."/" : "");			return($this->ValidateEmailAddress($email));		}		return(eregi($this->email_regular_expression,$email)!=0);	}	Function ValidateEmailHost($email,&$hosts)	{		if(!$this->ValidateEmailAddress($email))			return(0);		$user=$this->Tokenize($email,"@");		$domain=$this->Tokenize("");		$hosts=$weights=array();		$getmxrr=$this->getmxrr;		if(function_exists($getmxrr)		&& $getmxrr($domain,$hosts,$weights))		{			$mxhosts=array();			for($host=0;$host<count($hosts);$host++)				$mxhosts[$weights[$host]]=$hosts[$host];			KSort($mxhosts);			for(Reset($mxhosts),$host=0;$host<count($mxhosts);Next($mxhosts),$host++)				$hosts[$host]=$mxhosts[Key($mxhosts)];		}		else		{			if(strcmp($ip=@gethostbyname($domain),$domain)			&& (strlen($this->exclude_address)==0			|| strcmp(@gethostbyname($this->exclude_address),$ip)))				$hosts[]=$domain;		}		return(count($hosts)!=0);	}	Function VerifyResultLines($connection,$code)	{		while(($line=$this->GetLine($connection)))		{			$this->last_code=$this->Tokenize($line," -");			if(strcmp($this->last_code,$code))				return(0);			if(!strcmp(substr($line, strlen($this->last_code), 1)," "))				return(1);		}		return(-1);	}	Function ValidateEmailBox($email)	{		if(!$this->ValidateEmailHost($email,$hosts))			return(0);		if(!strcmp($localhost=$this->localhost,"")		&& !strcmp($localhost=getenv("SERVER_NAME"),"")		&& !strcmp($localhost=getenv("HOST"),""))		   $localhost="localhost";		if(!strcmp($localuser=$this->localuser,"")		&& !strcmp($localuser=getenv("USERNAME"),"")		&& !strcmp($localuser=getenv("USER"),""))		   $localuser="root";		for($host=0;$host<count($hosts);$host++)		{			$domain=$hosts[$host];			if(ereg('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$domain))				$ip=$domain;			else			{				if($this->debug)					$this->OutputDebug("Resolving host name \"".$hosts[$host]."\"...");				if(!strcmp($ip=@gethostbyname($domain),$domain))				{					if($this->debug)						$this->OutputDebug("Could not resolve host name \"".$hosts[$host]."\".");					continue;				}			}			if(strlen($this->exclude_address)			&& !strcmp(@gethostbyname($this->exclude_address),$ip))			{				if($this->debug)					$this->OutputDebug("Host address of \"".$hosts[$host]."\" is the exclude address");				continue;			}			if($this->debug)				$this->OutputDebug("Connecting to host address \"".$ip."\"...");			if(($connection=($this->timeout ? @fsockopen($ip,25,$errno,$error,$this->timeout) : @fsockopen($ip,25))))			{				$timeout=($this->data_timeout ? $this->data_timeout : $this->timeout);				if($timeout				&& function_exists("socket_set_timeout"))					socket_set_timeout($connection,$timeout,0);				if($this->debug)					$this->OutputDebug("Connected.");				if($this->VerifyResultLines($connection,"220")>0				&& $this->PutLine($connection,"HELO $localhost")				&& $this->VerifyResultLines($connection,"250")>0				&& $this->PutLine($connection,"MAIL FROM: <$localuser@$localhost>")				&& $this->VerifyResultLines($connection,"250")>0				&& $this->PutLine($connection,"RCPT TO: <$email>")				&& ($result=$this->VerifyResultLines($connection,"250"))>=0)				{					if($result)					{						if($this->PutLine($connection,"DATA"))							$result=($this->VerifyResultLines($connection,"354")!=0);					}					else					{						if(strlen($this->last_code)						&& !strcmp($this->last_code[0],"4"))							$result=-1;					}					if($this->debug)						$this->OutputDebug("This host states that the address is ".($result ? ($result>0 ? "valid" : "undetermined") : "not valid").".");					fclose($connection);					if($this->debug)						$this->OutputDebug("Disconnected.");					return($result);				}				if($this->debug)					$this->OutputDebug("Unable to validate the address with this host.");				fclose($connection);				if($this->debug)					$this->OutputDebug("Disconnected.");			}			else			{				if($this->debug)					$this->OutputDebug("Failed.");			}		}		return(-1);	}};?>

Arquivo DNS.php

<?php/* ------------------------------------------------------------------------   PHPresolver - PHP DNS resolver library				 Version 1.1   Copyright (c) 2001, 2002 Moriyoshi Koizumi <koizumi@ave.sytes.net>   All Rights Reserved.   This library is free software; you can redistribute it and/or modify it   under the terms of the GNU Lesser General Public License as published   by the Free Software Foundation; either version 2.1 of the License, or any   later version.   This library is distributed in the hope that it will be useful, but   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public   License for more details.   You should have received a copy of the GNU Lesser General Public License   along with this library; if not,   write to the Free Software Foundation, Inc.,   59 Temple Place, Suite 330, Boston, MA 02111-1307  USA  ------------------------------------------------------------------------*/	define( "DNS_RECORDTYPE_A", 1 );	define( "DNS_RECORDTYPE_NS", 2 );	define( "DNS_RECORDTYPE_CNAME", 5 );	define( "DNS_RECORDTYPE_SOA", 6 );	define( "DNS_RECORDTYPE_PTR", 12 );	define( "DNS_RECORDTYPE_MX", 15 );	define( "DNS_RECORDTYPE_AAAA", 28 );	define( "DNS_RECORDTYPE_ANY", 255 );		define( "DNS_RECORDTYPE_TXT", 16 );/*	list of record types not yet implemented	define( "DNS_RECORDTYPE_A6", 38 );	define( "DNS_RECORDTYPE_NULL", 10 );	define( "DNS_RECORDTYPE_OPT", 41 );	define( "DNS_RECORDTYPE_TKEY", 249 );	define( "DNS_RECORDTYPE_TSIG", 250 );	define( "DNS_RECORDTYPE_IXFR", 251 );	define( "DNS_RECORDTYPE_AXFR", 252 );	define( "DNS_RECORDTYPE_MAILB", 253 );	define( "DNS_RECORDTYPE_MAILA", 254 );	define( "DNS_RECORDTYPE_MD", 3 );	define( "DNS_RECORDTYPE_MF", 4 );	define( "DNS_RECORDTYPE_MB", 7 );	define( "DNS_RECORDTYPE_MG", 8 );	define( "DNS_RECORDTYPE_MR", 9 );	define( "DNS_RECORDTYPE_WKS", 11 );	define( "DNS_RECORDTYPE_HINFO", 13 );	define( "DNS_RECORDTYPE_MINFO", 14 );	define( "DNS_RECORDTYPE_RP", 17 );	define( "DNS_RECORDTYPE_AFSDB", 18 );	define( "DNS_RECORDTYPE_X25", 19 );	define( "DNS_RECORDTYPE_ISDN", 20 );	define( "DNS_RECORDTYPE_RT", 21 );	define( "DNS_RECORDTYPE_NSAP", 22 );	define( "DNS_RECORDTYPE_NSAP_PTR", 23 );	define( "DNS_RECORDTYPE_SIG", 24 );	define( "DNS_RECORDTYPE_KEY", 25 );	define( "DNS_RECORDTYPE_PX", 26 );	define( "DNS_RECORDTYPE_GPOS", 27 );	define( "DNS_RECORDTYPE_LOC", 29 );	define( "DNS_RECORDTYPE_NXT", 30 );	define( "DNS_RECORDTYPE_EID", 31 );	define( "DNS_RECORDTYPE_NIMLOC", 32 );	define( "DNS_RECORDTYPE_SRV", 33 );	define( "DNS_RECORDTYPE_ATMA", 34 );	define( "DNS_RECORDTYPE_NAPTR", 35 );	define( "DNS_RECORDTYPE_KX", 36 );	define( "DNS_RECORDTYPE_CERT", 37 );*/	define( "DNS_OPCODE_QUERY" , 0x0000 );	define( "DNS_OPCODE_IQUERY", 0x0800 );	define( "DNS_OPCODE_STATUS", 0x1000 );	define( "DNS_OPCODE_NOTIFY", 0x1800 );	define( "DNS_OPCODE_UPDATE", 0x2000 );	define( "DNS_RCODE_SUCCESSFUL"   , 0x0001 );	define( "DNS_RCODE_MALFORMATED"  , 0x0002 );	define( "DNS_RCODE_FAILEDSERVER" , 0x0003 );	define( "DNS_RCODE_NAMEERROR"	, 0x0004 );	define( "DNS_RCODE_UNIMPLEMENTED", 0x0005 );	define( "DNS_RCODE_REFUSED"	  , 0x0006 );	define( "DNS_HEADERSPEC_IS_RESPONSE"		 , 0x8000 );	define( "DNS_HEADERSPEC_OPCODE_MASK"		 , 0x7800 );	define( "DNS_HEADERSPEC_AUTHORITIVE_ANSWER"  , 0x0400 );	define( "DNS_HEADERSPEC_TRUNCATED"		   , 0x0200 );	define( "DNS_HEADERSPEC_RECURSION_DESIRED"   , 0x0100 );	define( "DNS_HEADERSPEC_RECURSION_AVAILABLE" , 0x0080 );	define( "DNS_HEADERSPEC_RESPONSE_SPEC_MASK"  , 0x0480 );	define( "DNS_HEADERSPEC_QUERY_SPEC_MASK"	 , 0x0300 );	define( "DNS_HEADERSPEC_RESERVED"			, 0x0e00 );	define( "DNS_HEADERSPEC_RESULT_CODE_MASK"	, 0x000f );	define( "DNS_CLASS_INTERNET"				 , 0x0001 );	define( "DNS_UDP_PACKET_MAX_LENGTH", 512 );	class	DNSRecord	{		var	$type;		var	$name;		var	$dclass;		var	$ttl;		var $specific_fields;		function DNSRecord(		  $name,		  $type,		  $dclass = DNS_CLASS_INTERNET,		  $ttl = 0,		  $specific_fields = false ) {			$this->name = $name;			$this->type = $type;			$this->dclass = $dclass;			$this->ttl = $ttl;			$this->specific_fields = $specific_fields;		}		function &getTypeSpecificField( $name ) {			if( $this->specific_fields ) {				return $this->specific_fields[$name];			}			return false;		}	}	class	DNSResolver	{		var $port;		var $nameserver;		var $timeout;		function DNSResolver( $nameserver, $port = 53, $timeout = 1000000 ) {			$this->port = $port;			$this->nameserver = $nameserver;			$this->timeout = $timeout;		}		function sendQuery( $dnsquery, $useTCP = false ) {			$answer = false;			$out_buf = $dnsquery->asOctets( false );			$out_buf_len = strlen( $out_buf );			if( $out_buf ) {				if( $useTCP == false && $out_buf_len <= DNS_UDP_PACKET_MAX_LENGTH ) {					/* connection by UDP */					if( ( $sock = fsockopen( 'udp://'.$this->nameserver, $this->port, $this->timeout ) ) === false ) {						return false;					}					socket_set_blocking( $sock, true );					if( fwrite( $sock, $out_buf ) == $out_buf_len ) {						$answer = new DNSAnswer( $sock, DNS_UDP_PACKET_MAX_LENGTH );					}					fclose( $sock );				} else {					/* connection by TCP */					if( ( $sock = fsockopen( $this->nameserver, $this->port, $this->timeout ) ) === false ) {						return false;					}					socket_set_blocking( $sock, true );					if( fwrite( $sock, pack( 'n', $out_buf_len ) ) == 2 &&						fwrite( $sock, $out_buf ) == $out_buf_len ) {						$tmp = unpack( 'nl', fread( $sock, 2 ) );						$limit_length = $tmp['l'];						print $limit_length;						$answer = new DNSAnswer( $sock, $limit_length );					}					fclose( $sock );				}			}			return $answer;		}	}	class	DNSQuery 	{		var $id; // 1 - 65535		var $header_opcode;		var $query_record;		var $flags;		function DNSQuery( &$dnsrecord, $flags = DNS_HEADERSPEC_RECURSION_DESIRED )		{			$this->id = rand( 1, 255 ) | ( rand( 0, 255 ) << 8 );			$this->flags = $flags & DNS_HEADERSPEC_QUERY_SPEC_MASK;			$this->header_opcode = DNS_OPCODE_QUERY;			$this->query_record = &$dnsrecord;		}		function asOctets() {			if( $this->query_record->name === false ) { return false; }			$buf = '';			$buf .= pack( "nnnnnn", $this->id, DNS_OPCODE_QUERY | $this->flags, 1, 0, 0, 0 );			$buf .= $this->query_record->name->asOctets();			$buf .= pack( "nn", $this->query_record->type, $this->query_record->dclass );			return $buf;		}	}	class	DNSMessageParser	{		var $stream;		var $nbytes_read;		var $octets;		var $limit;		function DNSMessageParser( $stream, $limit ) {			$this->stream = $stream;			$this->nbytes_read = 0;			$this->octets = '';			$this->limit = $limit;		}		function readStreamDirectly( $nbytes ) {			if( ( $this->limit -= $nbytes ) < 0 ) {				return false;			}			$buf = fread( $this->stream, $nbytes );			$this->octets .= $buf;			$this->nbytes_read += $nbytes;			return $buf;		}		function readBufferedStream( $nbytes, $offset ) {			if( $offset < $this->nbytes_read ) {				$diff = $this->nbytes_read - $offset;				if( $nbytes <= $diff ) {					return substr( $this->octets, $offset, $nbytes );				} else {					$buf = substr( $this->octets, $offset, $diff );					$nbytes -= $diff;				}			} else {				$buf = '';				while( $offset > $this->nbytes_read ) {					if( $this->readStreamDirectly( $offset - $this->nbytes_read ) === false ) {						return false;					}				}			}			if( ( $_buf = $this->readStreamDirectly( $nbytes ) ) === false ) {				return false;			}			$buf .= $_buf;			return $buf;		}		function getHeaderInfo() {			if( ( $buf = $this->readStreamDirectly( 12 ) ) === false ) {				$this = false;				return;			}			return unpack( "nid/nspec/nqdcount/nancount/nnscount/narcount", $buf );		}		function getQueryRecords( $nrecs ) {			$recs = array();			while( --$nrecs >= 0 ) {				if( ( $labels = $this->getLabels() ) === false ) {					$this = false;					return;				}				if( ( $buf = $this->readStreamDirectly( 4 ) ) === false ) {					$this = false;					return;				}				$info = unpack( "ntype/ndclass", $buf );				$recs[] = new DNSRecord(					new DNSName( $labels ),					$info['type'],					$info['dclass']				);			}			return $recs;		}		function getResourceRecords( $nrecs ) {			$recs = array();			while( --$nrecs >= 0 ) {				if( ( $labels = $this->getLabels() ) === false ) {					return false;				}				if( ( $buf = $this->readStreamDirectly( 10 ) ) === false ) {					return false;				}				$info = unpack( "ntype/ndclass/Nttl/nrdlength", $buf );				switch( $info['type'] ) {					case DNS_RECORDTYPE_CNAME:					case DNS_RECORDTYPE_NS:					case DNS_RECORDTYPE_PTR:						if( ($_labels = $this->getLabels($info['rdlength']) ) === false ) {							return false;						}						$specific_fields = array( 'dname' => new DNSName( $_labels ) );						break;					case DNS_RECORDTYPE_TXT:						if( ($_labels = $this->getLabels($info['rdlength']) ) === false ) {							return false;						}						$specific_fields = array( 'text' => $_labels );						break;					case DNS_RECORDTYPE_MX:						if( ( $buf = $this->readStreamDirectly(2) ) === false ) {							return false;						}						$specific_fields = unpack( 'npreference', $buf );						if( ( $_labels = $this->getLabels($info['rdlength']-2) ) === false ) {							return false;						}						$specific_fields['exchange'] = new DNSName( $_labels );						break;					case DNS_RECORDTYPE_A:						if( ( $buf = $this->readStreamDirectly(4) ) === false ) {							return false;						}						$specific_fields = array( 'address' => DNSName::newFromString( implode( '.', unpack( 'Ca/Cb/Cc/Cd', $buf ) ) ) );						break;					case DNS_RECORDTYPE_AAAA:						if( ( $buf = $this->readStreamDirectly(16) ) === false ) {							return false;						}						$specific_fields = array( 'address' => DNSName::newFromString( implode( '.', unpack( 'Ca/Cb/Cc/Cd/Ce/Cf/Cg/Ch/Ci/Cj/Ck/Cl/Cm/Cn/Co/Cp', $buf ) ).'.IP6.ARPA' ) );						break;					case DNS_RECORDTYPE_SOA:						$specific_fields = array();						if( ($_labels = $this->getLabels($info['rdlength']) ) === false ) {							return false;						}						$specific_fields['source'] = new DNSName( $_labels );						if( ($_labels = $this->getLabels($info['rdlength']) ) === false ) {							return false;						}						$specific_fields['resp_person'] = array_shift( $_labels ).'@';						$specific_fields['resp_person'] .= implode( '.', $_labels );						if( ( $buf = $this->readStreamDirectly(20) ) === false ) {							return false;						}						$specific_fields = array_merge(							$specific_fields,							unpack( 'Nserial/Nrefresh/Nretry/Nexpire/Nminttl', $buf )						);						break;					default:						if( $this->readStreamDirectly( $info['rdlength'] ) === false ) {							return false;						}						$specific_fields = false;				}				$recs[] = new DNSRecord(					new DNSName( $labels ),					$info['type'],					$info['dclass'],					$info['ttl'],					$specific_fields				);			}			return $recs;		}		function getLabels( $max_length = 255, $offset = -1 ) {			if( $offset < 0 ) { $offset = $this->nbytes_read; }			$labels = array();			for(;;) {				if( --$max_length < 0 ) { return false; }				if( ( $buf = $this->readBufferedStream( 1, $offset ) ) === false ) {					return false;				}				$label_len = ord( $buf );				++$offset;				if( $label_len < 64 ) {					/* uncompressed */					if( ( $max_length -= $label_len ) < 0 ) { return false; }					if( ( $labels[] = $this->readBufferedStream( $label_len, $offset ) ) === false ) {						return false;					}					$offset += $label_len;					if( $label_len == 0 ) { break; }				} else {					/* compressed */					if( ( $buf = $this->readBufferedStream( 1, $offset ) ) === false ) {						return false;					}					if( --$max_length < 0 ) {						return false;					}					$_offset = ( ( $label_len & 0x3f ) << 8 ) + ord( $buf );					if( ($_labels = $this->getLabels( $offset - $_offset, $_offset )) === false ) {						return false;					}					$labels = array_merge( $labels, $_labels );					break;				}			}			return $labels;		}	}	class	DNSAnswer	{		var $id;		var $result_code;		var $flags;		var $rec_query;		var $rec_answer;		var $rec_authority;		var $rec_additional;		function DNSAnswer( &$stream, $limit ) {			$msgparser = new DNSMessageParser( $stream, $limit );			$info = & $msgparser->getHeaderInfo();			$this->id = $info['id'];			$this->result_code = $info['spec'] & DNS_HEADERSPEC_RESULT_CODE_MASK;			$this->flags = $info['spec'] & DNS_HEADERSPEC_RESPONSE_SPEC_MASK;			$nrec_query = $info['qdcount'];			$nrec_answer = $info['ancount'];			$nrec_authority = $info['nscount'];			$nrec_additional = $info['arcount'];			if( ( $this->rec_query = &$msgparser->getQueryRecords( $nrec_query ) ) === false ) {				$this = false;				return;			}			if( ( $this->rec_answer = &$msgparser->getResourceRecords( $nrec_answer ) ) === false ) {				$this = false;				return;			}			if( ( $this->rec_authority = &$msgparser->getResourceRecords( $nrec_authority ) ) === false ) {				$this = false;				return;			}			if( ( $this->rec_additional = &$msgparser->getResourceRecords( $nrec_additional ) ) === false ) {				$this = false;				return;			}		}	}	class	DNSName	{		var	$labels;		function DNSName( $labels ) {			$this->labels = & $labels;		}		function isRealDomainName() {			$i = count( $this->labels ) - 1;			if( $i >= 1 && strtoupper($this->labels[$i-1]) == 'ARPA' ) {				return false;			}			return true;		}		function newFromString( $domain_name ) {			if( strpos( $domain_name, ':' ) !== false && !ereg( '[^0-9a-fA-f:.]', $domain_name ) ) {				/* IPv6 address literal expression spec */				$labels = array();				$components = explode( ':', $domain_name );				$ncomponents = count($components);				$offset = $ncomponents;				while( --$offset >= 0 ) {					$subcomps = explode( '.', $components[$offset] );					$nsubcomps = count( $subcomps );					if( $nsubcomps == 1 ) {						if( $subcomps[0] == '' ) {							$_offset = 0;							while( $components[$_offset] != '' ) {								++$_offset;							}							$count = 9-($ncomponents-$offset)+$_offset;							while( --$count >= 0 ) {								$labels[] = '0';								$labels[] = '0';								$labels[] = '0';								$labels[] = '0';							}							if( $_offset < $offset ) {								$offset = $_offset;							}						} else {							$compval = hexdec( $subcomps[0] );							$labels[] = dechex( $compval & 0x0f );							$compval >>= 4;							$labels[] = dechex( $compval & 0x0f );							$compval >>= 4;							$labels[] = dechex( $compval & 0x0f );							$compval >>= 4;							$labels[] = dechex( $compval & 0x0f );							$compval >>= 4;						}					} elseif( $nsubcomps == 4 ) {						$labels[] = dechex( $subcomps[3] );						$labels[] = dechex( $subcomps[2] );						$labels[] = dechex( $subcomps[1] );						$labels[] = dechex( $subcomps[0] );					} else {						return false;					}				}				$labels[] = 'IP6';				$labels[] = 'ARPA';				$labels[] = '';			} else {				if( substr( $domain_name, -1, 1 ) != '.' ) {					$domain_name .= '.';				}				$labels = explode( '.', $domain_name );				$nlabels = count( $labels );				if( $nlabels == 5 && !ereg( '[^0-9.]', $domain_name ) ) {					/* IPv4 raw address literal representation spec */					$tmp = (string)$labels[0];					$labels[0] = (string)$labels[3];					$labels[3] = $tmp;					$tmp = (string)$labels[1];					$labels[1] = (string)$labels[2];					$labels[2] = $tmp;					$labels[4] = 'IN-ADDR';					$labels[5] = 'ARPA';					$labels[6] = '';				}			}			return new DNSName( $labels );		}		function asOctets() {			$upto = count( $this->labels );			$buf = '';			for( $offset = 0; $offset < $upto; ++$offset ) {				$label_len = strlen( $this->labels[$offset] );				$buf .= pack( "C", $label_len ).$this->labels[$offset];			}			return $buf;		}		function getCanonicalName() {			return implode( ".", $this->labels );		}	}?>Finalmente o [b]Arquivo Formulario.htm[/b][code]<?php	require("email_validation.php");	$validator=new email_validation_class;	if(!function_exists("GetMXRR"))	{		$_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";	}	*/	$validator->timeout=10;	$validator->data_timeout=0;	/* user part of the e-mail address of the sending user	   (info@phpclasses.org 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;	$validator->exclude_address="";	$con = mysql_connect("localhost","user","password");		if (!$con){	die('Could not connect: ' . mysql_error());	}		mysql_select_db("databasename", $con);		//Determina para que emails vai enviar a Newsletter	$strSQL = "select * from newsletters_emails";	$result = mysql_query($strSQL);		while($row = mysql_fetch_array($result)){		$email = $row['email'];		list($user,$dominio) = explode("@", $email);				$validator->localuser=$user;		$validator->localhost=$dominio;				//echo '<div>'.$user.' | '.$dominio.'</div>';				if(($result=$validator->ValidateEmailBox($email))<0)			echo "<H2><CENTER>Não é possível determinar se <TT>$email</TT> é válido.</CENTER></H2>\n";		else			echo "<H2><CENTER><TT>$email</TT> is ".($result ? "" : "not ")." a valid deliverable e-mail box address.</CENTER></H2>\n";	}?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Creio que impossível.. não seja..

 

Vou dizer porque..

 

Quando você vai validar um e-mail, você precisa trabalhar por etapas.

A primeira delas, é verificar, se o endereço de e-mail digitado é realmente um e-mail válido.

Como sabemos isso? você pega o conteudo que foi digitado, e começa a procurar dentro dele:

Primeiro, precisa ter uma @.

Após encontrar a arroba, você precisa validar o que vem antes dela.. precisa ser um conjunto válido de caracter de no minimo 1.

Depois, precisa ter um outro conjunto válido de no minimo 1 caracter após a arroba. (não sei se precisamente é 1 o minimo permitido, mas supondo que seja..)

Então, precisa ter um domínio.. que você validaria buscando pelo "." ..

 

Essa seria a etapa 1.

 

Após esta etapa, talvez, creio que utilizando um componente, como por exemplo, xmlhttp, para procurar o domínio que tem após a arroba.. e verificar se o mesmo existe..

Se existir.. essa etapa tambem passaria adiante.

 

Depois, uma coisa que não sei dizer como poderia ser feita, seria mandar uma mensagem de teste.. e verificar o retorno com erro..

 

Creio que a idéia seria esta.. não sei se foi util.. mas me fez fazer algo que não fazia a muito tempo.. pensar como programador.. hehehe

 

abraços

Compartilhar este post


Link para o post
Compartilhar em outros sites

você consegue facilmente verificar se o e-mail digitado é válido, mas para verificar se um domínio é realmente existente, você consegue até ver se existe, mas terá que efetuar essa consulta sempre, pois a cada dia saun criados mais e mais dominios...

Compartilhar este post


Link para o post
Compartilhar em outros sites
imone.isa123 como postou para agradecer tudo bem mas leve em consideração a data do ultimo post se resolver colaborar com auxílios a outros mebros

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.