How can I add a script to sending mail using phpmailer?

Postcode in 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 do I add a script file? And also how to add "id" for the button and "onclick" for the accept and reject buttons? Please let me know how to pass values ​​to external javascript file on button click by mail.

+3


source to share


1 answer


You can not. Well, you can, but it won't work. I don't know of any email client (including web clients like gmail) that allows javascript to run in messages. Many are also garbage CSS, so you're really out of luck.



+2


source







All Articles