Beware this content is over 7 years old and considered stale. It may no longer be accurate and/or reflect the understanding of the author but remains here for reference only. Please keep this in mind as you use this content.

After setting up any server, I like to run some tests to make sure it’s all working.

One test I’ll run is just a simple mail script to double check the server can successfully send an e-mail. This makes sure my SMTP settings are correct and any Firewall is correctly configured.

After running my simple mail script, I received this PHP (5.3.14) warning:

Warning: mail(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for '2.0/DST' instead in C:\htdocs\mail-test.php on line 41

Note: Now you’ll only see this if you’re script is set to display all errors and warnings because it should not prevent your e-mail from being sent.

I expect that the line number and the assumed timezone might be different to the above depending on your script and where your server is located.

The best way to correct this issue is to head to your php.ini file and add the relevant timezone. The next best thing is to set the timezone using the date_default_timezone_set() function [each time] before using the mail() function.

You can find a full list of accepted timezones at:

You can find out where your php.ini is by checking the output of phpinfo(). In my version of PHP 5.3.14, the line I needed to change was at 975.

; Defines the default timezone used by the date functions
;date.timezone =

Just remove the semi-colon (;) and add your timezone.

date.timezone = Europe/London

Once done, restart Apache and try the script again.

Any problems beyond that, drop a comment if you get stuck.