Trigger an email after a user downloads a file

Recently we were asked how you can trigger an email after downloading of a file. This is how you do it, the below function adds a new email section in settings and the trigger fires off the email once a user has downloaded a file.