<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'mail/Exception.php';
require 'mail/PHPMailer.php';
require 'mail/SMTP.php';

//Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);




$nombre = strip_tags($_POST['name']);
$correo = strip_tags($_POST['email']);
$telefono = strip_tags($_POST['phone']);
$comentario = strip_tags($_POST['message']);

try {
    //Server settings
    $mail->SMTPDebug = 0;                      //Enable verbose debug output
    $mail->isSMTP();                                            //Send using SMTP
    $mail->Host       = 'mail1.correopremium.com';                     //Set the SMTP server to send through
    $mail->SMTPAuth   = true;                                   //Enable SMTP authentication
    $mail->Username   = 'callegariplasticos@callegariplasticos.com';                     //SMTP username
    $mail->Password   = 'Callegari#2o21%';                               //SMTP password
    $mail->SMTPSecure = 'ssl';         //Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
    $mail->Port       = 465;                                    //TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above

    //Recipients
    $mail->setFrom('callegariplasticos@callegariplasticos.com', 'Contacto WEB desde Callegari');
    $mail->addAddress('callegariplasticos@callegariplasticos.com', 'callegariplasticos@callegariplasticos.com');     //Add a recipient
    $mail->addAddress('comercial01@callegariplasticos.com', 'callegariplasticos@callegariplasticos.com');     //Add a recipient
    $mail->addAddress('mercadeo@insepet.com', 'mercadeo@insepet.com');     //Add a recipient

      //Content
    $mail->isHTML(true);                                  //Set email format to HTML
    $mail->Subject = 'Formulario desde Callegari';
    $mail->Body    =  "
<html>

<body>

<h3>Nuevo mensaje desde el formulario de contacto</h3>

<p><strong>Nombre:</strong> {$nombre}<br />

<strong>Email:</strong> {$correo}<br />

<strong>Telefono:</strong> {$telefono}<br />

<strong>Mensaje:</strong> {$comentario}</p>

</body>

</html>

<br />"; // Texto del email en formato HTML;


    $mail->send();
    header("location:gracias.html");
} catch (Exception $e) {
    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
