Can anyone tell me how I can create a 500 error to check if my error page, 500.php
, is ok? I would like to send e-mail alerts to myself when some types of error occurs, how can I do this?
I read a lot, but didn't find much.
Can anyone tell me how I can create a 500 error to check if my error page, 500.php
, is ok? I would like to send e-mail alerts to myself when some types of error occurs, how can I do this?
I read a lot, but didn't find much.
You can force it with
header('HTTP/1.1 500 Internal Server Error');
Then on your 500.php
page use mail()
For the point 2:
I would to send e-mail alerts to myself when some types of error occurs what track to follow ?
Use Google Webmasters tool:
http://www.google.com/webmasters/
Webmasters tools can help you to detect all the server errors and helps you to optimize your site, is a great tool.
More info:
http://en.wikipedia.org/wiki/Google_Webmaster_Tools
I think the easiest way to trigger and 500 error would be to load an invalid .htaccess file
So create a new directory somewhere where Apache can see it and in that directory upload a file named .htacesss with the following contents:
Redirect
This is invalid syntax since you aren't giving all the required Redirect parameters and will reliably generate a 500 error in my testing.
How to send an e-mail with php:
if($stuffExploded==true)
{
$to = 'nobody@example.com';
$subject = 'Oh, By the way...';
$message = 'Stuff exploded on page 64, line 221. Good going.';
mail($to, $subject, $message);
}