0

I have the following code at the top of a php error page:

<?php $message = "Your website has generated a 503 error"; mail('myaddress@mydomain.com', 'ALERT - 503 Error', $message); ?>

Obviously the email address above is substituted with my actual email on the live site.

When I load the page, no email is sent. Any ideas? Thanks.

Will Nicholls
  • 35
  • 1
  • 1
  • 8
  • Best to use a library that generates an error (*Like [PHPMailer](https://github.com/PHPMailer/PHPMailer)*). Also, have you tried actually sending the mail, with headers and all? – Darren Jan 29 '16 at 01:45
  • You should add headers `From:` like this: `$from = "info@yoursite.com"; $headers = "From:" . $from; $message = "Your website has generated a 503 error"; mail('yourmail@gmail.com', 'ALERT - 503 Error', $message, $headers);` – Abdul Rahman Mohsen Jan 29 '16 at 01:48
  • If the mail script still doesn't work when you add the headers argument, then you should open a support ticket and tell your hosting providers to allow the mail script for you on the server. – Abdul Rahman Mohsen Jan 29 '16 at 01:51

0 Answers0