I am trying to send an email with the phpmailer library, in local it works correctly, but when I have uploaded it to a hosting it returns the following error: Could not instantiate mail function.
The configuration I have is the following:
$nombre = $_POST['nombre'];
$email = $_POST['email'];
$mensaje = $_POST['mensaje'];
require_once('lib/phpmailer/class.phpmailer.php');
$mail = new PHPMailer();
//indico a la clase que use SMTP
$mail->isSMTP();
$mail->CharSet = "UTF-8";
//permite modo debug para ver mensajes de las cosas que van ocurriendo
$mail->SMTPDebug = 2;
//Debo de hacer autenticación SMTP
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
//indico el servidor de Gmail para SMTP
$mail->Host = "smtp.gmail.com";
//indico el puerto que usa Gmail
$mail->Port = 465;
//indico un usuario / clave de un usuario de gmail
$mail->Username = "[email protected]";
$mail->Password = "pass";
$mail->setFrom('[email protected]', 'Restaurante ');
$mail->addReplyTo($email, $nombre);
$mail->Subject = "Nuevo mensaje recibido .";
$mail->msgHTML($mensaje);
//indico destinatario
//$address = "[email protected]";
$address = "[email protected]";
$mail->addAddress($address, "Restaurante");
if(!$mail->send()) {
echo "Error al enviar: ". $mail->ErrorInfo;
} else {
echo "Mensaje enviado!";
}
Do you know what may be happening?
Thank you very much. Greetings.