Usage example – Download

Posted by php-manual on Jan 26, 2009 in |

Usage example - Download

Please remove .txt extension from filename after downloading

11 Comments

php-manual
Feb 11, 2009 at 12:47 pm

Download above file or see code below


< ?php

// the email to validate
$email = 'joe@gmail.com';
// an optional sender
$sender = 'user@example.com';
// instantiate the class
$SMTP_Valid = new SMTP_validateEmail();
// do the validation
$result = $SMTP_Valid->validate($email, $sender);
// view results
var_dump($result);
echo $email.' is '.($result ? 'valid' : 'invalid')."\n";

// send email?
if ($result) {
//mail(...);
}

?>


 
Nsthinh
Jun 24, 2009 at 9:20 am

Cannot re-assign $this in C:\Program Files\xampp\php\pear\Net\DNS\RR.php


 
Kaiser
Sep 4, 2009 at 4:16 am

Thanks for file and the php attachment


 
Jeremy
Jan 15, 2010 at 7:27 pm

Warning: Invalid argument supplied for foreach() on line: 90

When validating one email, like the example, not only does it fail but you get a PHP warning.
You have to explode the emails first to get this to work properly.

In the class, on line 120 put this:
$emails = explode(‘,’,$emails);

You can edit the separator to ; or whatever you like.

Hope this helps


 
srinu.galla
Jul 31, 2010 at 10:06 am

Iam checking email Address is valid or not ..
it works on gmail,but yahoo,reddif mails not checking
i have occured error:Error: h.mx.mail.yahoo.com said: 553 Mail from 124.123.190.226 not allowed – 5.7.1 [BL21] Connections not accepted from IP addresses on Spamhaus PBL; see postmaster.yahoo.com/errors/550-bl21.html [550]
please give reply
thanking you


 
iphp
Aug 13, 2010 at 9:55 am

@srinu.galla
It looks like your IP address is blacklisted for some reason. Please remove it from the Spamhaus blacklist and try again.


 
Bence
Dec 9, 2010 at 4:05 pm

Yeah!!! :-)

2 corrections needed:

1.) as mentioned above, insert the following after line 119 in smtpvalidateclass.php:
$emails = explode(‘,’,$emails);

2.) displaying the result must be like this:
echo $email.’ is ‘.($result[$email] ? ‘valid’ : ‘invalid’).”";

Now works well for me! :-) ) THANKS!!


 
georgefloros
Dec 17, 2010 at 12:56 pm

thnks for this awesome example it helps me alot


 
purvesh
Jan 13, 2011 at 1:05 pm

please give me Net/DNS.php page download


 
Nick
Feb 2, 2011 at 9:39 pm

The following always returned an empty string (”):

preg_match(‘/^([0-9]{3}) /ims’, $reply, $matches);
$code = isset($matches[1]) ? $matches[1] : ”;

So I changed it to something much simpler and more accurate:

$rlt = explode(” “,$reply);
$code = $rlt[0];

$reply is in the format of
I exploded on the space and took the first element which is the status code.


 
Soal
Feb 15, 2011 at 11:12 am

Thanks, man, very useful article!

Net/DNS.php – it’s part of pear package, you can get it here: download.pear.php.net/package/Net_DNS-1.0.7.tgz or here: pear.php.net/package/Net_DNS/download (if previous link is outdated)


 

Reply

Copyright © 2012 PHP, Web and IT stuff All rights reserved. PHP Web development in London.