NoobLaPHP Posted March 5, 2014 Share Posted March 5, 2014 Ok, i am having a load of people register to a subscription service on my website using invalid emails. I would like to add a function in that can read an email. If the source is right it will continue to process the form. If it's not then it shows an error message. Would i use something like an explode function to seperate using the @ in an email and read the end part(live.co.uk) and then have an array set up to see if the end is in the email or what? Examples would be a great help if you have any other ideas. Thanks Link to comment https://forums.phpfreaks.com/topic/286715-email-verfication/ Share on other sites More sharing options...
NoobLaPHP Posted March 5, 2014 Author Share Posted March 5, 2014 I have found this that seems to work well. function domain_exists( $email, $record = 'MX' ) { list( $user, $domain ) = explode( '@', $email ); return checkdnsrr( $domain, $record ); } if(domain_exists('[email protected]')) { echo('This MX records exists; I will accept this email as valid.'); } else { echo('No MX record exists; Invalid email.'); } Source: http://davidwalsh.name/php-email-validator Link to comment https://forums.phpfreaks.com/topic/286715-email-verfication/#findComment-1471507 Share on other sites More sharing options...
cyberRobot Posted March 5, 2014 Share Posted March 5, 2014 For what it's worth, PHP has a built-in function for validating things like email addresses: http://www.php.net/manual/en/filter.examples.validation.php Link to comment https://forums.phpfreaks.com/topic/286715-email-verfication/#findComment-1471510 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.