Re: PEAR class to validate a recipient email address?
| From: | Al | Date: | Wed, 31 Mar 2010 19:03:41 +0000 |
| Subject: | Re: PEAR class to validate a recipient email address? | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-30427@lists.php.net to get a copy of this message | ||
On 3/31/2010 10:17 AM, Robert P. J. Day wrote:
On Wed, 31 Mar 2010, Robert P. J. Day wrote:I'm short on time or I've give you a more detailed response. Here is a snippet that might be helpful. Word wrap messes it up Obviously, there is an array() that has several addresses to be checked. And this is in a foreach loop. $tag = htmlentities($array[0]);//just for error message if(empty($array['addr']) || !filter_var($array['addr'], FILTER_VALIDATE_EMAIL) || !preg_match("%[[:alnum:][:punct:]]%", $array['addr']))is there a pear class that contains functionality to SMTP-validate an email address? that is, to verify that a given email address actually exists at the destination and is capable of receiving emails? googling around quickly found this: http://code.google.com/p/php-smtp-email-validation/ so i'm about to take a closer look at that. is there anything else people use that seems to work reliably? thanks.let me expand on the above slightly since i think it's going to make a difference. i'm primarily interested in validating email addresses that correspond to text messaging email addresses, for both SMS and MMS gateways. for example, i have a cell phone with Telus up here in Canada, whose SMS and MMS gateways are, respectively, msg.telus.com and mms.telusmobility.com. thus, if someone wants to send me a simple SMS text message, they can email it to<mynum>@msg.telus.com. if they want to send me a multi-part MIME message instead, they can send that to<mynum>@mms.telusmobility.com, and everything works fine. what i'd like is an SMTP validation routine that can handle *those* destination addresses -- phone numbers along with a carrier's gateway. i tried the code i pointed above and, sadly, it claims that my perfectly valid SMS address is not valid. conversely, it seemed to think that<mynum>@sms.sasktel.com *is* valid, even though i'm not using that carrier. in short, it appears that regular SMTP validation doesn't quite hold for email addresses corresponding to messaging. so i'm definitely open to suggestions, if there is, in fact, a way to do this. it's quite possible that there isn't. rday -- ========================================================================Robert P. J. Day Waterloo, Ontario, CANADALinux Consulting, Training and Kernel Pedantry.Web page: http://crashcourse.ca Twitter: http://twitter.com/rpjday========================================================================
{
throw new Exception("Email address error. Syntax is wrong for $tag");
}
$domain = substr(strchr($array['addr'], '@'), 1);
if(!checkdnsrr($domain))
{
throw new Exception("Email address warning. Specified domain \"$domain\" appears to be invalid in $tag. Check carefully.");
}
The only practical way I've found to validate actual account names is to check for bounces. Unfortunately, doesn't seem that the sms handlers bounce messages. I messed around with some schemes for checking accounts several folks suggested; but, none worked reliably for me.