0

I have this script for sending emails

<?php
$nome = stripslashes($_POST['name']);
$telefone = stripslashes($_POST['telefone']);
$email = stripslashes($_POST['email']);
$text = stripslashes($_POST['message']);
$response = $_POST['captcha'];
$secret = "---";

$verify=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret={$secret}&response={$response}");

$captcha_success = json_decode($verify);

if($captcha_success-> success == false)
{
    echo json_encode(['success'=>false]);
}
else if($captcha_success-> success == true)
{
    $to = '---';
    $subject = 'Contacto Geral';

    // To send HTML mail, the Content-type header must be set
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

    // Compose a simple HTML email message
    $message = '<html><body>';
    $message .=  '<h1 style="font-size:18px;">Contacto Geral</h1>';
    $message .= '<p>Nome:' . $nome . '</p>';
    $message .= '<p>Telefone:' . $telefone . '</p>';
    $message .= '<p>Email:' . $email . '</p>';
    $message .= '<p>Message:' . $text. '</p>';
    $message .= '</body></html>';

    if(mail($to, $subject, $message, $headers))
    {
        echo json_encode(['success'=>true]);
    }
    else
    {
        echo json_encode(['success'=>false]);
    }

}
?>

The problem is that this script is not sending to the domain email. It works to every other email and I tried with lots of them. I don't know how to solve this problem. I already tried to re-write the code again but it still does not work. Does anyone how how to solve this proble or if my code is wrong somehow?

Alexandre Cristo
  • 341
  • 3
  • 16

0 Answers0