perezf Posted August 21, 2008 Share Posted August 21, 2008 Is there a way in php to check if a email is valid, I want to run a script that will check all of my emails in a file so that way i dont get any bounce backs from non existent emails. Link to comment https://forums.phpfreaks.com/topic/120639-php-email-check/ Share on other sites More sharing options...
JasonLewis Posted August 21, 2008 Share Posted August 21, 2008 Well you can check for a valid email format, not sure on checking if it is a real email account. I guess that's up to the truthfulness of users. Search google for "PHP regex email validation" Link to comment https://forums.phpfreaks.com/topic/120639-php-email-check/#findComment-621802 Share on other sites More sharing options...
bluejay002 Posted August 21, 2008 Share Posted August 21, 2008 I agree with ProjectFear. (as far as I know) The best thing you can do to is to create email verification. Link to comment https://forums.phpfreaks.com/topic/120639-php-email-check/#findComment-621827 Share on other sites More sharing options...
Fadion Posted August 21, 2008 Share Posted August 21, 2008 I'm not aware of a way to validate email existence, and if it exists, it must be a bit complicated. What I know, is a way of checking if the mail domain has mx records. Normally, as suggested previously you must run a regular expression to validate the email format. Consider this code: <?php $email = '[email protected]'; list($name, $domain) = explode('@', $email); //will explode the '@' to get two variables for the domain and name if(checkdnsrr($domain, 'MX')){ //will check the dns of the domain for any MX records. you can discard the second parameter as the default is 'MX' but i wrote it for you to understand it echo 'Your email is valid.'; } else{ echo 'Sorry, email invalid.'; } ?> Unfortunately (or not) you can't use this function in windows platforms, but maybe a command such as "nslookup" can be used in the same way. Hope someone can give you a better method. Link to comment https://forums.phpfreaks.com/topic/120639-php-email-check/#findComment-621829 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.