user852974
user852974

Reputation: 2282

PHP / HTML5 solution to validating emails and sending validated ones to an email address

Can someone recommend a good php mailer that sends the contents of this single input

    <form method="POST" action="mailer.php">
       <div id="emailform"><input type="text" name="email" class="keywords" placeholder="[email protected]" id="subscribetext"></div>
    </form>

In an email to a specified address, and also verifies the contents to be a valid email? Thanks.

Also html5 can validate emails? Is this a better way to go?

Upvotes: 0

Views: 550

Answers (2)

nickw444
nickw444

Reputation: 966

<?php
$email = $_POST['email'];
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
//code to excecute if email is invalid
}
else
{
//code to excecute if email is valid.
}

?>

This will use php's inbuilt email address validation. For javascript/HTML5, have a look at some regular expressions.

Upvotes: 1

kgilden
kgilden

Reputation: 10356

You might want to look into SwiftMailer.

Upvotes: 0

Related Questions