I have a form that I want to send with PHPmailer, but I want to send it without using SMTP, since I would like it when the emails arrive, where it says "FROM:" appears the email of the sender. In fact, with the code below I had already achieved it but I stop working this week. When checking the mailing, he sends me the error message: "Could not instantiate mail function" How could I solve it.
Here my code:
<?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_once ('phpmailer/PHPMailerAutoload.php');
//Nuevo correo electronico.
$mail = new PHPMailer();
$mail->Host =
//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. El error es: ".$mail->ErrorInfo;
} 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 :(";
}
? >