<?php

//Import the PHPMailer class into the global namespace
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require './vendor/autoload.php';

//require '/var/www/html/appmail.appliedballisticsllc.com/public_html/vendor/phpmailer/phpmailer/src/Exception.php';
//require '/var/www/html/appmail.appliedballisticsllc.com/public_html/vendor/phpmailer/phpmailer/src/PHPMailer.php';
//require '/var/www/html/appmail.appliedballisticsllc.com/public_html/vendor/phpmailer/phpmailer/src/SMTP.php';

$mail = new PHPMailer(true); 

try {
    //Server settings
    $mail->SMTPDebug = 2;                                                                    // Enable verbose debug output
    $mail->isSMTP();                                                                         // Set mailer to use SMTP
    $mail->Host = 'smtp.mail.us-east-1.awsapps.com';                                         // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                                                                  // Enable SMTP authentication
    $mail->Username = 'appmail@appliedballisticsllc.com';                                    // SMTP username
    $mail->Password = 'UWcXG9taOg1TpaaSyROA%@yfcuYCLw1l!crl%&1ghpcz$Q4FN^Jh#yabWHaRXcjT';    // SMTP password
    $mail->SMTPSecure = 'ssl';                                                               // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 465;                                                                       // TCP port to connect to
	
	if (!empty($_GET['encoding'])) {
		$mail->CharSet = $_GET['encoding'];                                                  // Set the charset (likely "UTF-8")
	}


    //Recipients
    $mail->setFrom('appmail@appliedballisticsllc.com', 'Applied Ballistics');
    $mail->addReplyTo('appmail@appliedballisticsllc.com', 'Applied Ballistics');

    $addresses = explode(",", $_POST['email']);
    foreach($addresses as $address) {
        $mail->addAddress($address);                                                         // Add a recipient
    }

    //Content
    $mail->isHTML(true);                                                                     // Set email format to HTML
    $mail->Subject = $_POST["subject"];
    $mail->Body    = $_POST["body"];
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

    $mail->send();
    echo 'Message has been sent<br>';
}

catch (Exception $e) {
    echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo, '<br>';
}

echo getcwd();

?> 

