This script is intended to be used with Open VPN as the client-connect and client-disconnect scripts, to send an email using Mailgun to a certain address when a client connects or disconnects.
To install this, copy the below file to /etc/openvpn/statuschange.sh, replace the to email with your own, the and the from email, the URL, and the API key with your own Mailgun login. (I use the sandbox because I didn't feel like messing with DNS.)
Then, add the following to /etc/openvpn/server.conf:
client-connect /etc/openvpn/statuschange.sh
client-disconnect /etc/openvpn/statuschange.sh
script-security 2