I am making a system that will be used to collect data from users. I know some will be spam! I just want to know if the mail function returns false if the email is not correct?
Say I have.
<?php
$to = "fake@fake.com";
$header = "From: {$to}";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body, $header)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>
Which message will be printed if the email is not correct?
If it does return false I want a “flag” to be stored with it in that database so the admins can review it and delete it.
Not necessarily.
Per the manual, the
mail()function will returntrueif the message is accepted for delivery – but doesn’t guarantee that it will be delivered: