Basic Text Email

<?php

$mail = new PHPMailer();

$mail->From     = "[email protected]";
$mail->FromName = "Full Name";
$mail->addReplyTo("[email protected]", "Reply Address");
$mail->Subject  = "Subject Text";
$mail->Body     = "This is a sample basic text email using PHPMailer.";

if($mail->send()) {
    // Success! Redirect to a thank you page. Use the
    // POST/REDIRECT/GET pattern to prevent form resubmissions
    // when a user refreshes the page.
  
    header('Location: <http://example.com/path/to/thank-you.php>', true, 303);
    exit;
} 
else {
    echo "Mailer Error: " . $mail->ErrorInfo;
}

Adding addtional recipients, CC recipients, BCC recipients

<?php

$mail = new PHPMailer();

$mail->From     = "[email protected]";
$mail->FromName = "Full Name";
$mail->addReplyTo("[email protected]", "Reply Address");
$mail->addAddress("[email protected]", "Recepient Name");
$mail->addAddress("[email protected]"); 
$mail->addCC("[email protected]");
$mail->addBCC("[email protected]");
$mail->Subject  = "Subject Text";
$mail->Body     = "This is a sample basic text email using PHPMailer.";

if($mail->send()) {
    // Success! Redirect to a thank you page. Use the
    // POST/REDIRECT/GET pattern to prevent form resubmissions
    // when a user refreshes the page.
  
    header('Location: <http://example.com/path/to/thank-you.php>', true, 303);
    exit;
} 
else {
    echo "Error: " . $mail->ErrorInfo;
}