I can't figure out what I'm doing here. I admit I'm a bit of a newb.
I'm trying to have a script that checks the format of an email address, and then checks to make sure the domain has an mx record.
<?php
if ($emailaddress && $question){
$emailaddress = $_POST['emailaddress'];
$question = $_POST['question'];
}
print "$emailaddress\n\n";
print "$question\n\n";
if (!$emailaddress || !$question){
print "<form action='/~Bryan/newtest.php' name='emailchecker' type='post'>
Email address: <input type='text' value='$emailaddress' name='emailaddress'>
Question: <br><br>
<textarea rows='6' cols='34' name='question'>$question</textarea>
<input type=submit>
</form>
";
}
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $emailaddress)) {
echo "That email doesn appear to be formatted";
exit;
}else{
echo "that email is formatted correctly...";
}
list( $Username, $Domain )=split("@",$emailaddress);
if(getmxrr($Domain, $MXHost)){
echo "and has an MX host.";
}else{
echo "but the remote server doesn't have an MX host.";
}
?>