如何将脚本添加到使用 phpmailer 发送的邮件?
How do I add script to the mail send using phpmailer?
PHP 中的邮件代码:
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Training Program';
$mail->Body = "<html><head><script type = "."text/javascript"." "."src = "."pgm_mgmt.js"."></script>Dear<b> ".$trainername[$i].","."</b>"."<br><br>I'd like to know if you can attend the "."<b>".$trainerpgmname."</b>"." held at "."<b>".$trainercompany."</b>"." on "."<b>".$trainerdate."</b>"."<br><br>You can either accept or reject the request by clicking the Accept or Reject buttons below <br>"."<button"." "."name = ".$trainerid[$i]." "."value = ".$accept." "."onclick = accept(".$trainerid[$i].")".">Accept</button>"." "."<button"." "."name = reject".$trainerid[$i]." "."value = ".$reject.">Reject</button>";
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
我应该如何在其中添加脚本文件?还有如何为按钮添加 "id" 并为接受和拒绝按钮添加 "onclick"?请让我知道如何通过单击邮件中的按钮将值传递给外部 javascript 文件
你不能。好吧,你可以,但它不会工作。我不知道有任何电子邮件客户端(包括像 gmail 这样的 Web 客户端)允许在消息中使用 运行 javascript。还有很多垃圾 CSS,所以你真的很倒霉。
PHP 中的邮件代码:
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Training Program';
$mail->Body = "<html><head><script type = "."text/javascript"." "."src = "."pgm_mgmt.js"."></script>Dear<b> ".$trainername[$i].","."</b>"."<br><br>I'd like to know if you can attend the "."<b>".$trainerpgmname."</b>"." held at "."<b>".$trainercompany."</b>"." on "."<b>".$trainerdate."</b>"."<br><br>You can either accept or reject the request by clicking the Accept or Reject buttons below <br>"."<button"." "."name = ".$trainerid[$i]." "."value = ".$accept." "."onclick = accept(".$trainerid[$i].")".">Accept</button>"." "."<button"." "."name = reject".$trainerid[$i]." "."value = ".$reject.">Reject</button>";
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
我应该如何在其中添加脚本文件?还有如何为按钮添加 "id" 并为接受和拒绝按钮添加 "onclick"?请让我知道如何通过单击邮件中的按钮将值传递给外部 javascript 文件
你不能。好吧,你可以,但它不会工作。我不知道有任何电子邮件客户端(包括像 gmail 这样的 Web 客户端)允许在消息中使用 运行 javascript。还有很多垃圾 CSS,所以你真的很倒霉。