Reputation: 167
Mail Code 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 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? Please do let me know how can I pass the values to a external javascript file on click of the button in the mail
Upvotes: 3
Views: 652
Reputation: 37770
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. Many also trash CSS, so you're really out of luck.
Upvotes: 2