Jump to content

If Not Email Address


computermax2328

Recommended Posts

Hello All,

 

If I have a newsletter process script with name and email, is there a way to identify if the email is an email address? For example [email protected].

 

I kind of want to think of a way to identify if it is a real name as well. Maybe just ask for first and last name.

 

Thanks,

Link to comment
https://forums.phpfreaks.com/topic/270298-if-not-email-address/
Share on other sites

You could use a regular expression to see if the string is in a valid email address format. It doesn't however guarantee it is an actual email address.

 

That is why sites use email verification. If you want force your users into supplying an email address that works, you need to verify it up front.

They have a PHP command for everything. I love PHP!

 

In the simplest form, something like this??

$email = $_GET['email'];
if(filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) {
echo "This is not a valid email";
}
else {
mail($email, "Please Validate");
}

 

I understand there are no headers or message.

They have a PHP command for everything. I love PHP!

 

In the simplest form, something like this??

$email = $_GET['email'];
if(filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) {
echo "This is not a valid email";
}
else {
mail($email, "Please Validate");
}

 

I understand there are no headers or message.

The PHP function checks if the email address is correctly build up.

But it doesn't say anything if the domain name exists.

 

I wrote a small example, which after the PHP check also checks if the domain name exists:

 

http://www.wmappz.com/php/validate-email-address/

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.