【问题标题】:how do i sort out this warning on my php mail page我如何在我的 php 邮件页面上解决这个警告
【发布时间】:2017-12-14 12:16:58
【问题描述】:

我尝试使用我的 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';
    }

提前致谢

【问题讨论】:

标签: php function email time fixed


【解决方案1】:

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

您可以在脚本中使用 PHP 函数 date_default_timezone_set() 和时区 List of Supported Timezones

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-01
    • 2020-10-24
    • 2016-04-20
    • 2019-08-26
    相关资源
    最近更新 更多