Trouble PHPMailer + Gmail

Status
Not open for further replies.

albertgx

New Member
Messages
1
Reaction score
0
Points
1
Hi! I need your help, I was trying to send emails from a form using PHPMailer but it has a problem.
When I try to send the email in localhost with XAMPP works fine, but here in X10 not.

Any suggestion?

There is my code of function sendEmail.php


<?php

require "../PHPMailer/src/Exception.php";
require "../PHPMailer/src/PHPMailer.php";
require "../PHPMailer/src/SMTP.php";

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

$oMail = new PHPMailer();

$name = $_POST['contactName'];
$email = $_POST['contactEmail'];
$asunto = $_POST['contactSubject'];
$mensaje = $_POST['contactMessage'];


$oMail->isSMTP();
$oMail->Host = "smtp.gmail.com";
$oMail->Port = 587;
$oMail->SMTPSecure = "tls";
$oMail->SMTPAuth = true;
$oMail->Username = "kek@gmail.com";
$oMail->Password = "passkek";

$oMail->setFrom("kek@gmail.com", "kek email");
$oMail->addAddress("random@gmail.com");
$oMail->Subject = $asunto;
$oMail->msgHTML("Mensaje enviado por: " . $name . "<" . $email . ">" . "A través de kek <br />" . $mensaje);


if(!$oMail->send()){
echo "<script>
alert('Mensaje no enviado, por favor verifica los datos');
window.location = '../index.php'
</script>";
}else{
echo "<script>
alert('Mensaje Enviado con Éxito');
window.location = '../index.php'
</script>";

}

?>
 
Status
Not open for further replies.
Top