<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
require 'vendor/phpmailer/phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer; //Create a new PHPMailer instance
$body = "<h3>Registro</h3>
<strong>Nombre:</strong>".$_POST['nombre']."<br/>
<strong>Ciudad:</strong>".$_POST['ciudad']."<br/>
<strong>Telefono:</strong>".$_POST['telefono']."<br/>
<strong>Email:</strong>".$_POST['email']."<br/>
<strong>Mensaje:</strong>".$_POST['mensaje']."<br/>
";
$mail->isSMTP(); //Tell PHPMailer to use SMTP
$mail->SMTPDebug = 4; //Enable SMTP debugging
$mail->Debugoutput = 'html'; //Ask for HTML-friendly debug output
$mail->Host = 'smtp.gmail.com'; //Set the hostname of the mail server
$mail->Port = 587; //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->SMTPSecure = 'tls'; //Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPAuth = true; //Whether to use SMTP authentication
$mail->Username = "mail@gmail.com"; //Username to use for SMTP authentication - use full email address for gmail
$mail->Password = "123456789"; //Password to use for SMTP authentication
$mail->setFrom('mail@gmail.com', 'First Last'); //Set who the message is to be sent from
$mail->addReplyTo('mail@gmail.com', 'First Last'); //Set an alternative reply-to address
$mail->addAddress('mail@gmail.com', 'John Doe'); //Set who the message is to be sent to
$mail->Subject = 'Mensaje Usuario Micovinoc landing'; //Set the subject line
$mail->msgHTML($body); //convert HTML into a basic plain-text alternative body
$mail->AltBody = 'Mensaje Usuario Micovinoc landing'; //Replace the plain text body with one created manually
if (!$mail->send()) { //send the message, check for errors
echo "Error al enviar email: " . $mail->ErrorInfo;
} else {
return json_encode(array('state' => 1));
}
?>