Reputation: 35
I worked Google's Captcha into my html form and into the php handler. When I fill in the form (and do correctly), I get the message MAIL SEND but I think the php is not sending an email. I'm not receiving any mails... This form and php worked without recaptcha but now I think there's a mistake in my code. Can anyone help me with it? Thanks in advance!
<?php
// grab recaptcha library
require_once "recaptchalib.php";
// your secret key
$secret = "---";
// empty response
$response = null;
// check secret key
$reCaptcha = new ReCaptcha($secret);
// if submitted check response
if ($_POST["g-recaptcha-response"]) {
$response = $reCaptcha->verifyResponse(
$_SERVER["REMOTE_ADDR"],
$_POST["g-recaptcha-response"]
);
if(isset($_POST['submit'])) {
$to = "[email protected]";
$subject = "Contact ---.synology.me";
$name_field = $_POST['username'];
$sex = $_POST['sex'];
$email_field = $_POST['email'];
$password1 = $_POST['pwd1'];
$password2 = $_POST['pwd2'];
$comment = $_POST['comment'];
$body = " NL\n Afzender: $name_field\n Geslacht: $sex\n Emailadres:
$email_field\n Wachtwoord 1: $password1\n Wachtwoord 2: $password2\n
Suggestie: $comment\n";
echo "<script>
if(confirm('MAIL SEND!')){
window.location.href = 'https://---.synology.me/account-aanvragen.html';
}else{
window.location.href = 'https://---.synology.me/account-aanvragen.html';
}
</script>";
$headers = "From: [email protected]" . "\r\n";
mail($to, $subject, $body, $headers);
} else {
echo "Er ging iets mis, probeer opnieuw of contacteer de administrator op [email protected]!";
}
} else {
echo "<script>
if(confirm('Bevestig dat je geen robot bent!')){
window.location.href = 'https://---.synology.me/account-aanvragen.html';
}else{
window.location.href = 'https://---.synology.me/account-aanvragen.html';
}
</script>";
}
?>
Upvotes: 0
Views: 1618
Reputation: 81
You can't send email from [email protected] without SMTP protocol.Your emails probably sended but hotmail is probably rejected your email thinking it's spam.So you should use smtp and log in with your password and email.
You can use phpMailer to send email.
Upvotes: 1
Reputation: 240
I always use a library or framework method to send emails. There are many and distinct problems that you find in this process, from server configuration, escape of content mail, headers and more. I recommend that use phpMailer for example. With this library you will be trace the process and detect your problem.
Upvotes: 1