It was a while ago that I first read ALA’s article on how to craft a more useful 404 error message. Yesterday implementing a more useful 404 hit the top of my to-do list. In the end I found a perfect off-the-peg PHP solution from Harold Bakker; “Mail on 404“. Does just what I need, in PHP. Grrreat.
Couple of additions:
Add the time zone
date_default_timezone_set('Europe/Madrid') ; into the PHP block Just above
$today = date("j F Y, G:i:s"); to set the time zone (a requirement for PHP5 I believe)
Add a recipient switch
I’ve added a recipient switch (not actually a PHP Switch but a bunch of if elseif else statements) to this so that the email message is sent to different e-mail accounts according to the server host name. This keeps my dev tests and snafus away from clogging up the client’s email.
Last Updated on 5th September 2018 by Gabriel de Kadt