Jump to content

verify email not working


dyr

Recommended Posts

Hi all, I'm trying to add a section where it verifies that the email address is active in my register code.  My code below is it checking the dnsrr, and if it is not real, I have it die and an error message appears.  However, I am getting the error message all the time, whether I am sure the email is working or not.  First I declared my email variable ($email), and then after the code below I of course insert the new data in to the database.  I'm doing this over my localhost, so is that why it can't verify emails?  Or am I setting this up wrong?

 

<?php

$email = trim($_POST['email']);

if (False !== strpos($email, '@')) 
die("Please type in an email address.<br><br><a href=register.php>Continue</a>");

if(!@checkdnsrr($mailDomain,'MX'))
die("Not real email address.  Please try again.<br><br>
<a href=register.php>Continue</a>");

?>

Link to comment
https://forums.phpfreaks.com/topic/258219-verify-email-not-working/
Share on other sites

 

Ah, I see.  So how would I set this up similar to my example above (making an if false, die function)? 

 

<?php function validateEmailAddress($email) {
    if return filter_var(!$email, FILTER_VALIDATE_EMAIL) && preg_match('/@.+\./', $email);
}  die("That email address does not exist.");

?>

 

Code above doesn't work, but had to give it my best shot at trying to negate it. 

validating the syntax/format of an address is different from validating the actual existence of the address.

 

Consider if hosts allowed simple validation how much greater the spamming would become.  Best way to validate is send and email asking user to verify.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.