我如何在我的php邮件页面上整理这个警告

时间:2017-12-14 12:16:58

标签: php function email time fixed

我尝试使用我的php邮件功能发送电子邮件,但我在进程中收到此警告

警告:mail():依赖系统是不安全的 时区设置。你是 要求使用 date.timezone设置或 date_default_timezone_set() 功能。如果您使用任何这些方法而且您是 你仍然得到这个警告 最有可能拼写错误的 时区标识符。我们 选择时区'UTC'为 现在,但请设置date.timezone来选择你的 时区。在

我的问题是如何修复我的php邮件功能的时间,以便在我的php邮件页面上读出此警告 这是我的代码:

  $to      = xvy@gmail.com        $message = yes go email;
    $subject = 'the subject';
    $time = date_default_timezone_set('Africa/Lagos');
    $headers = 'From: stringemail@gm.Com';

    $go = mail($to, $subject, $message, $headers);
    if ($go)
    {
        echo 'good result';
    }

非常感谢提前

1 个答案:

答案 0 :(得分:0)

您需要为整个PHP环境定义时区。

您可以使用PHP函数date_default_timezone_set()在您的脚本中使用时区List of Supported Timezones执行此操作:

 <?php 
 date_default_timezone_set('Africa/Lagos');
 // rest of your script goes here...