Error sending mail with PHP Mailer

0

I have a form that I send by mail using PHP Mailer, it worked perfectly when I put it in a site at the end of last year, but today the client informs me that every time he tries to send the form, the error message that I defined appears to do the shipping check, and I do not know what the problem might be, implement the same form for several pages of the site and the same thing happens in all of them.

<?php
$nombre = $empresa = $correo = $asunto = $mensaje = $captcha = $para = NULL;
$nombre = $_POST["nombre"];
$empresa = $_POST["empresa"];
$correo = $_POST["correo"];
$asunto = $_POST["asunto"];
$mensaje = $_POST["mensaje"];
$captcha = $_POST["captcha"];
$para = '[email protected]';

$keySecret = "6LfFFi4UAAAAAOhZGnLHXftPBG4dHL-sq8_DfR3Y";
$verificacion = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret={$keySecret}&response={$captcha}");
$respGoogle = json_decode($verificacion);

if($respGoogle->success == true){
    //echo "OK. Google validó el captcha :)";
    //Reseteamos variables a 0.

      //Componemos nuestro correo electronico

      //Incluimos libreria PHPmailer (deberas descargarlo).
      require 'phpmailer/PHPMailerAutoload.php';


      //Nuevo correo electronico.
      $mail = new PHPMailer();
      //Caracteres.
      $mail->CharSet = 'UTF-8';

      //De dirección correo electrónico y el nombre
      $mail->From = $correo;
      $mail->FromName = $nombre;

      //Dirección de envio y nombre.
      $mail->addAddress($para, "IMECPLAST");
      //Dirección a la que responderá destinatario.
      $mail->addReplyTo($correo,$nombre);

      //BCC ->  incluir copia oculta de email enviado.
      $mail->addBCC("[email protected]");

      //Enviar codigo HTML o texto plano.
      $mail->isHTML(true);

      //Titulo email.
      $mail->Subject = $asunto;
      //Cuerpo email con HTML.
      $mail->Body = "
              <h1>Correo de Prueba</h1>

              Nombre: $nombre<br />
                      Empresa: $empresa<br />
              Email: $correo <br />
              Mensaje: $mensaje <br />

      "; 
    //Comprobamos el envio.
    if(!$mail->send()) {                   
        echo "Mensaje no Enviado vuelva a intentar";
    } else {
        echo "<b>Hemos recibido tu mensaje, te contestaremos lo más pronto posible</b>";
    } 
}
else if($respGoogle->success == false){
    echo "Error. Google no validó el captcha :(";
}
?>

That is the code that you use, and since you get to the message "Message Not Sent, try again" I rule out that it is a captcha error. Any idea what the problem might be?

In this link the form is in case it is useful.

    
asked by José Carlos Castillo 28.05.2018 в 20:11
source

0 answers