<?php
//Import PHPMailer classes into the global namespace
//These must be at the top of your script, not inside a function
 $pathRoot = $_SERVER['DOCUMENT_ROOT'];
require  $pathRoot ."/saia/api/v1/libs/PHPMailer-master/src/PHPMailer.php";
require  $pathRoot ."/saia/api/v1/libs/PHPMailer-master/src/Exception.php";
require  $pathRoot ."/saia/api/v1/libs/PHPMailer-master/src/SMTP.php";

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

//Load Composer's autoloader
//require 'vendor/autoload.php';

//Create an instance; passing `true` enables exceptions
$mail = new PHPMailer(true);

try {
    //Server settings
   // $mail->SMTPDebug = SMTP::DEBUG_SERVER;                      //Enable verbose debug output
    $mail->SMTPDebug = SMTP::DEBUG_OFF; 
    $mail->isSMTP();                                            //Send using SMTP
    $mail->Host       = 'mail.saimage-apps.co.za';                     //Set the SMTP server to send through
    $mail->SMTPAuth   = true;                                   //Enable SMTP authentication
    $mail->Username   = 'helpdesk@saimage-apps.co.za';                     //SMTP username
    $mail->Password   = '.@-1slkDk$U.';                               //SMTP password
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;            //Enable implicit TLS encryption
    $mail->Port       = 465;                                    //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`

    //Recipients
    $mail->setFrom('helpdesk@saimage-apps.co.za', 'Mailer');
    $mail->addAddress('gits.sa@gmail.com', 'Emile');     //Add a recipient
    $mail->addAddress('emile@ideas4apps.co.za');               //Name is optional
    $mail->addReplyTo('emile@ideas4apps.co.za', 'Information');
   // $mail->addCC('cc@example.com');
   // $mail->addBCC('bcc@example.com');

    //Attachments
  //  $mail->addAttachment('/var/tmp/file.tar.gz');         //Add attachments
  //  $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    //Optional name

    //Content
    $mail->isHTML(false);                                  //Set email format to HTML
    $mail->Subject = 'Here is the subject';
    $mail->Body    = 'Test1';
    $mail->AltBody = 'Test2';

    $mail->send();
    echo 'Message has been sent';
} catch (Exception $e) {
    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}