I used the following solution to send the email. Thank you, everyone, for lending your helping hand. I need help with how I can reference I want to reference the <DIV> with ID=qamaildivas a PHP variable at the top of this script. How can I represent a block of HTML code as a PHP variable as explained above?
Thank you in advance.
<?php
// My initial PHP code. Removing it here because of privacy concerns. :)
// Then added the PHP mailer
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
//Load Composer's autoloader
require 'vendor/autoload.php';
$mail = new PHPMailer(true); // Passing `true` enables exceptions
$mail;
try {
//Server settings
$mail->SMTPDebug = 1; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'HOSTNAME'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'USER EMAIL ID'; // SMTP username
$mail->Password = 'PASSWORD'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom('sendFROMemailID', 'Heading');
$mail->addAddress('sendTOEMAILID','NAME'); // Add a recipient
// $mail->addAddress('ellen@example.com'); // Name is optional
// $mail->addReplyTo('info@example.com', 'Information');
// $mail->addCC('cc@example.com');
// $mail->addBCC('bcc@example.com');
//Attachments (if any)
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
//Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Congratulations!</title>
</head>
<body>
<div>
<form method="post" action="publishqa_true.php">
<div contentEditable="true" class="qamaildiv" id="qamaildiv">
Dear ,<br><br>
Regarding QA of Canvas ID: <?php echo $Term;?><br><br>
<p>We are very pleased to say that your above course has satisfied all blah Success and therefore is ready to teach out of Canvas.</p>
<p>Students will now be given access to the blah course shell seven days prior to the class start date.</p>
<p>We would like to sincerely thank you for all of your efforts in embracing blah and helping to improve the blah experience. We provided our personal notes for each of the blah below:</p>
Kind Regards,<br><br>
INSERT SIGNATURE<br>
</div><br>
<input class="ch-button" type="submit" name="submit" value="Send Email">
</form>
</div>
</body>
</html>
// Prewritten footer file loading at the bottom of this file
<?php require_once("../private/layout/footer.php"); ?>