<?php
require 'lib/PHPMailer-master/src/PHPMailer.php';
require 'lib/PHPMailer-master/src/SMTP.php';
require 'lib/PHPMailer-master/src/Exception.php';
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
//echo "tu name es: ".$name."</br>";
//echo "email es: ".$email."</br>";;
//echo "message es: ".$message."</br>";
//echo ("Fecha: ".$name." | Nombre: ".$name);
if($name=="" || $email=="" || $message == "")
{
echo '<script>alert("Complete the required fields");</script>';
}else{
//Create a new PHPMailer instance
//$mail = new PHPMailer;
$mail = new \PHPMailer\PHPMailer\PHPMailer();
//$mail = new PHPMailer(true);
//Tell PHPMailer to use SMTP
//$mail->isSendMail(); //or $mail->isSMTP();
$mail->isSMTP();//or $mail->isSendMail();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
$mail->Timeout=60;
$mail->Helo = "dominio.com"; //Muy importante para que llegue a hotmail y otros
//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587;
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "interlux.ve@gmail.com";
//Password to use for SMTP authentication
$mail->Password = "J302876516";
//Set who the message is to be sent from
$mail->setFrom(''.$email.'', ''.$name.'');
//Set an alternative reply-to address
$mail->addReplyTo(''.$email.'', ''.$name.'');
//Set who the message is to be sent to
$mail->addAddress(''.$email.'');
//Set the subject line
$mail->Subject = ''.$email.'';
//$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
$mail->Body = '<h1>'.$message.'</h1>';
$mail->IsHTML(true);
//send the message, check for errors
if (!$mail->send()) {
//echo "Mailer Error: " . $mail->ErrorInfo;
echo '<script>alert("Mailer Error:'.$mail->ErrorInfo.'");</script>';
} else {
//echo "Message sent: ".$message;
echo '<script>alert("Message sent...");</script>';
}
}
?>