I have a PHP sending a contact form email, when it is in the captcha check condition, I receive the sent message, but the email is not delivered, and when I shoot the condition the email arrives normal. Follow the PHP code (The submit is done by ajax)
<?php
$captcha = $_POST['captcha'];
if (!empty($_POST['captcha'])) {
$resposta = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=SECRET-KEY&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
if ($resposta.success) {
$to = "[email protected]";
$nome = $_POST["nome"];
$email = $_POST["email"];
$mensagem = $_POST["mensagem"];
$celular = $_POST["celular"];
$assunto = $_POST["assunto"];
$txt = "MENSAGEM: $mensagem". "\r\n" . "CELULAR: $celular". "\r\n" . "NOME: $nome";
$headers = "From: $email";
if ((empty($nome))||(empty($email))||(empty($celular))||(empty($mensagem))||(empty($assunto))) {
print('Preencha os campos');
} else {
$envio = mail($to,$assunto,$txt,$headers);
if ($envio) {
print('Enviado');
}else{
print('Erro');
}
}
} else {
print('Erro');
}
} else {
print('Marque o Captcha');
}
?>