如何使用ID作为PHP变量的同一脚本引用下面的div?
<?php
$variableIDqamaildiv -> How should I assign it to the DIV with the ID below
?>
<div contentEditable="true" class="qamaildiv" id="qamaildiv">
Dear <?php echo $ccname; ?>,<br><br>
Regarding QA of Canvas ID: <?php echo $courseTerm;?><br><br>
<p>Students will now be given access to the Canvas course shell seven days prior to the class start date.</p>
<p>If you have any questions, please contact <a href="mailto:abc@abc.com?Subject=QA%20Query%20regarding%20<?php echo $_POST['code_term']?>">abc@abc.com</a>.</p>
Kind Regards,<br><br>
INSERT SIGNATURE
</div>
答案 0 :(得分:0)
下面是一个有效的示例。尽管您需要对其进行优化。
<script type="text/javascript">
function sendEmail(){
elm = document.getElementById('send_email');
elm.href = "mailto:abc@abc.com?subject=subject of the email&body="+ document.getElementById('qamaildiv').innerHTML;
}
</script>
</head>
<body>
<a href="#" onclick="return sendEmail();" id="send_email">Send Email</a>
<div contentEditable="true" class="qamaildiv" id="qamaildiv" >
Dear <?php echo $ccname; ?>,<br><br>
Regarding QA of Canvas ID: <?php echo $courseTerm;?><br><br>
<p>Students will now be given access to the Canvas course shell seven days prior to the class start date.</p>
<p>If you have any questions, please contact <a href="mailto:abc@abc.com?Subject=QA%20Query%20regarding%20<?php echo $_POST['code_term']?>">abc@abc.com</a>.</p>
Kind Regards,<br><br>
INSERT SIGNATURE
</div>
</body>
</html>
答案 1 :(得分:0)
我使用以下解决方案发送电子邮件。谢谢大家,帮助您。我需要有关如何引用的帮助,我想在脚本的顶部使用<DIV>
作为ID=qamaildiv
变量来引用PHP
。如上所述,如何将HTML
代码块表示为PHP
变量?
谢谢。
<?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"); ?>