简体   繁体   English

如何使用phpmailer将脚本添加到邮件发送?

[英]How do I add script to the mail send using phpmailer?

Mail Code in PHP: 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';

How should I add script file in this? 我该如何在此添加脚本文件? And also how do I add "id" for the button and "onclick" for the accept and reject buttons? 此外,如何为按钮添加“id”,为“接受”和“拒绝”按钮添加“onclick”? Please do let me know how can I pass the values to a external javascript file on click of the button in the mail 请告诉我如何在点击邮件中的按钮时将值传递给外部javascript文件

You can't. 你不能。 Well you can, but it won't work. 嗯,你可以,但它不会工作。 I don't know of any email clients (including web clients like gmail) that allow running javascript in messages. 我不知道任何允许在邮件中运行javascript的电子邮件客户端(包括gmail等网络客户端)。 Many also trash CSS, so you're really out of luck. 许多人也垃圾CSS,所以你真的不走运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM