<?php

require('assets/phpmailer2/PHPMailer2.php');

$mail = new codeworxtech\PHPMailer2();

try {

  $mail->SMTP_Debug     = 2; // 0 = off, 1 = basic, 2 = advanced
  $mail->SMTP_Host      = "mail.yourdomain.com";
  $mail->SetSMTPAccount( [ "yourname@yourdomain.com" => "yourpassword" ] );

  $mail->SetSender( ["name@yourdomain.com" => "First Last" ] );
  $mail->AddRecipient( ["johndoe@otherdomain.com" => "John Doe" ] );
  $mail->AddBCC( ["whogetsBCC@yourdomain.com" => "First Last" ] );

  $mail->Subject        = "PHPMailer2 Test Subject via SMTP, basic with authentication";
  $mail->MessageHTML    = file_get_contents('contents.html');
  $mail->MessageText    = "To view the message, please use an HTML compatible email viewer!";

  $mail->AddAttachment($_SERVER['DOCUMENT_ROOT'] . "/phpmailer2/data/phpmailer2.gif");
  $mail->AddAttachment($_SERVER['DOCUMENT_ROOT'] . "/phpmailer2/data/phpmailer2_mini.gif");

  if ($mail->Send()) {
    echo 'Message has been sent.';
  }
} catch (Exception $e) {
  echo $e->errorMessage();
}

?>
