PHP 4.1.1 mail function sent time is 16 hours ahead

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SWEETTEDDY
Forum Newbie
Posts: 3
Joined: Thu Oct 28, 2010 5:14 am

PHP 4.1.1 mail function sent time is 16 hours ahead

Post 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.
Last edited by Benjamin on Thu Oct 28, 2010 7:45 pm, edited 1 time in total.
Reason: Added [syntax=php] tags.
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

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

Post 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
SWEETTEDDY
Forum Newbie
Posts: 3
Joined: Thu Oct 28, 2010 5:14 am

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

Post 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.
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

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

Post by klevis miho »

Yeah you are right, it seems that the function is for PHP 5 >= 5.1.0
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

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

Post by klevis miho »

Try this instead:

putenv("TZ=US/Eastern");

Replace US/Eastern with your timezone
SWEETTEDDY
Forum Newbie
Posts: 3
Joined: Thu Oct 28, 2010 5:14 am

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

Post by SWEETTEDDY »

Hi,

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