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

require __DIR__ . '/vendor/autoload.php';

$mail = new PHPMailer(true);

try {
    // SMTP Configuration
    $mail->isSMTP();
    $mail->Host       = 'email-smtp.us-east-1.amazonaws.com';
    $mail->SMTPAuth   = true;
    $mail->Username   = 'AKIAWG5UMZF72YF7N5WE';
    $mail->Password   = 'BNRB9xxXnt/8K5+l1b0oPsP4KqSbuOGWy9vYBaA1zuIM';
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
    $mail->Port       = 587; // use 465 instead of 587
    

    // Sender
    $mail->setFrom('support@accounts-books.info', 'Test Email');

    // Recipient
    $mail->addAddress('vikas.rai@mightywarner.com', 'Vikas Rai');

    // Content
    $mail->isHTML(true);
    $mail->Subject = 'AWS SES Test Email';
    $mail->Body    = '<b>Hello!</b><br>This email was sent via <b>AWS SES SMTP</b> using PHPMailer.';
    $mail->AltBody = 'Hello! This is a plain text version.';

    // Send it
    $mail->send();
    echo "✅ Email sent successfully!";
} catch (Exception $e) {
    echo "❌ Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
