html - PHP mail() not receiving the email -
this question has answer here:
i'm trying set contact me page , i've got working way point of 'message sent' result showing correctly. e-mail never shows me in box inbox.
<?php $name = $_post['name']; $email = $_post['email']; $subject = $_post['subject']; $message = $_post['message']; $antispam = $_post['antispam']; $to = 'myemailaddress@gmail.com'; $from = 'from : ' . $email; $body = "from: $name\n e-mail: $email\n message:\n $message"; if ($antispam == '10' || 'ten' || 'ten') { $human = true; } if($_post['submit'] && $name != "" && $email != "" && $message != "" && $subject != "") { if ($human == true) { if (mail($to, $subject, $body, $from)) { $result = "your message sent successfully!"; } else { $result = "something went wrong! try sending message again"; } } else { $result = "you answered anti-spam answer incorrectly. please try again."; } } else { $result = "you did not fill out required field. please try again."; } ?> <?php echo $result; ?>
i've read seperately gmail has issues php mail(), possibly cause?
i found answer , feel dumber not recognizing it.
it never told send email, check if sending true or not. know sounds weird here's old code:
if ($human == true) { if (mail($to, $subject, $body, $from)) { $result = "your message sent successfully!"; } else { $result = "something went wrong! try sending message again"; }
and here's fixed version
if ($human == true) { mail($to, $subject, $body, $from); if (mail($to, $subject, $body, $from)) { $result = "your message sent successfully!"; } else { $result = "something went wrong! try sending message again"; }
to short, added mail($to, $subject, $body, $from);
after check see if $human == true
Comments
Post a Comment