Page 1 of 1

PHP 4.1.1 mail function sent time is 16 hours ahead

Posted: Thu Oct 28, 2010 5:26 am
by SWEETTEDDY
Hi All,

I am facing a problem when using the SMTP to send email through the web page interface. I using the PHP 4.1.1 version. The sent time is incorrect. The sent time is 16 hours ahead. I hope that I can get a solution for this problem.

Codes :

Code: Select all

<?php
$to = "sweetteddy@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";  
?>
php.ini file
[mail function]
SMTP = <-- i point to my mail server


Need help... Thanks.

Re: PHP 4.1.1 mail function sent time is 16 hours ahead

Posted: Thu Oct 28, 2010 5:39 am
by klevis miho
This is because the server time is 16 hours ahead.
Use this function to set your timezone http://php.net/manual/en/function.date- ... ne-set.php

Re: PHP 4.1.1 mail function sent time is 16 hours ahead

Posted: Thu Oct 28, 2010 7:29 pm
by SWEETTEDDY
Hi,

I get this error when using the date_default_timezone_set. Fatal error: Call to undefined function: date_default_timezone_set() in c:\apache\htdocs\plbcmdb\defect\date.php on line 37. Are there any other ways to solve this problem. I using PHP 4.1.1, it seem like don't have the date_default_timezone. Thanks.

Re: PHP 4.1.1 mail function sent time is 16 hours ahead

Posted: Fri Oct 29, 2010 5:59 am
by klevis miho
Yeah you are right, it seems that the function is for PHP 5 >= 5.1.0

Re: PHP 4.1.1 mail function sent time is 16 hours ahead

Posted: Fri Oct 29, 2010 6:15 am
by klevis miho
Try this instead:

putenv("TZ=US/Eastern");

Replace US/Eastern with your timezone

Re: PHP 4.1.1 mail function sent time is 16 hours ahead

Posted: Sun Oct 31, 2010 7:51 pm
by SWEETTEDDY
Hi,

Thanks so much. You help me solve my problem. Thanks. :D