PHP default timezone warning for mail() on Windows
Beware this content is over 4 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.
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
You can find a full list of accepted timezones at: php.net/timezones
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.
Just remove the semi-colon (;) and add your timezone.
Once done, restart Apache and try the script again.
Any problems beyond that, drop a comment if you get stuck.