Added internal error mail logging support

Adds support for sending a mail to administrators whenever an Internal Error (500) occurs.
Should work (it is taken as-is from a different project) but it has not been fully tested here.