I needed to add a custom firewall rule to my ESXi box, so that it could send email notifications.
Firstly, I created an smtp.xml file (see below) and this is stored on one of my datastores (in my case /vmfs/volumes/datastore2/hp/).
To make this persistent across reboots add the following lines to:
cp /vmfs/volumes/datastore2/hp/smtp.xml /etc/vmware/firewall/ chmod 444 /etc/vmware/firewall/smtp.xml esxcli network firewall refresh
Content of smtp.xml:
To add a cron job see this post