1

I have made a form that once submitted sends a set of details to the client email using the mail() in php.

The email has html encoding with two buttons: Accept and Reject.

Is there a way to capture the click event from inside the email if Accept or Reject button is pressed in the received email? If yes, how? (Can't find any info on this) And will it also work on all email clients? I am currently testing it in my gmail account.

random_user_name
  • 25,694
  • 7
  • 76
  • 115
ASO
  • 85
  • 6
  • 4
    They have to be full links to a URL, where you would then process the results. Example: `https://example.com?token=[some_good_hash]&response=accept`. - otherwise, NO. The email client(s) will NOT trigger a "php event" from an email. The only way is with a link. – random_user_name May 16 '18 at 18:39
  • I am thinking on using a JS script inside my html email to call my script. Is it ok? – ASO May 16 '18 at 18:41
  • 1
    Nope. JS won't run reliably inside an email client: https://stackoverflow.com/questions/3054315/is-javascript-supported-in-an-email-message and https://kb.mailchimp.com/campaigns/design/limitations-of-html-email - the link option I described is the only way. – random_user_name May 16 '18 at 18:41
  • Do you mean to link the button to a full URL? If so then it will have to be the URL to my server side script? – ASO May 16 '18 at 18:45
  • Yes. A link to your server side script, including `$_GET` parameters to indicate to your script (a) Who clicked the link (please, don't pass a user id - use a hash or token), and (b) what response they are providing (accept or reject). Ideally the token would expire after a period of time, so that your script wouldn't be (as) vulnerable to brute force attacks. – random_user_name May 16 '18 at 18:48
  • I see, I'll try that. Thanks a lot. – ASO May 16 '18 at 18:55
  • As mentioned before, you cannot run JavaScript in email. No popular client will let you do this. You can use a form, but that's about it. – gwally May 16 '18 at 20:10

0 Answers0