<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require '../includes/Exception.php';
require '../includes/PHPMailer.php';
//require "PHPMailerAutoload.php";
require '../includes/SMTP.php';


$nome = "Pippo";
$cognome = "Baudo";
$email = "webmaster@elenchitelefonici.it";
$mailHtml = "Test Corpo Email";
$altMail = "Test Alt Corpo Email";

 try {

    // configurazione invio email
    $mail = new PHPMailer(true);
  
    $mail->isSMTP();
    $mail->SMTPDebug = 4;
    $mail->Mailer = "smtp";
    $mail->Host       = 'mail.labakeca.eu';                    // Set the SMTP server to send through
    $mail->SMTPAuth   = true;                                   // Enable SMTP authentication
    $mail->SMTPAutoTLS = true; 
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;         // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` also accepted
    #$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
    $mail->Username   = 'back@labakeca.eu';                     // SMTP username
    $mail->Password   = 'MGX7W7UCFJL';                               // SMTP password
    $mail->Port = 587; // or 465                                 // TCP port to connect to

    $mail->setFrom('test@labakeca.eu','Informazioni labakeca.eu');
    $mail->addReplyTo('test@labakeca.eu','Informazioni labakeca.eu');
    $mail->addAddress($email,"$nome $cognome");
    $mail->isHTML(true);
    $mail->Subject = "$nome, conferma la tua partecipazione";
    $mail->Body = $mailHtml;
    $mail->altBody = $altMail;
    
    $mail->send();
    echo 'Message has been sent';
} catch (Exception $e) {
    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
?>