You can put scripts in /www/cgi-bin/ directory and execute them like this: http://192.168.1.1/cgi-bin/script
This way you will be able to execute commands through URL.
And regarding the emails, there is command that look like this:
echo -e "subject:test\nfrom:testemail@gmail.com\n\ntestestestestest" | sendmail -v -H "exec openssl s_client -quiet -connect smtp.gmail.com:587 -tls1 -starttls smtp" -f testemail@gmail.com -au"testemail@gmail.com" -ap"lalalal" receiveremail@gmail.com
To set it up: https://myaccount.google.com/ > Security > App Passwords
You can program your script to execute commands and then send email as the response/status of executed command and it's output.
EB.