Question:
The time is wrong on my emails sent by php sendmail script?
ookami007
2008-12-21 08:14:41 UTC
I am sending emails using the php sendmail script. The problem is, the server is on a different timezone than I am and the emails appear to have been send 5 hours before. Is there a way to change the time sent on email in php? I am using php on a Windows platform - v5.0
Five answers:
anonymous
2008-12-21 09:13:20 UTC
Add the datetime you want to use as an additional header.




date_default_timezone_set( "America/New_York" );

$now = new DateTime();



$to = "you@you.com";

$header = "From: me@me.com\r\nDate: " . date_format($now, 'r');

$subject = "foobar";

$body = "hello world";



mail( $to, $subject, $body, $header );

?>
SSE
2008-12-22 15:08:34 UTC
Version 5 of PHP is not an "older" version, it's still actually pretty new, as v6 is not in widespread use yet.



Other than that, I can only suggest that you look into mail headers. There are options for time/date there.
anonymous
2008-12-24 08:25:27 UTC
I found a site good for programmers to ask questions. There are some experienced programmers there, so you can get help there. It's free by the way.



http://www.geekpolice.net/
I Love Ubuntu
2008-12-21 16:24:24 UTC
if you look at source #1, it will have the syntax for the mail(); function. Date looks like it should be in the additional headers section. Try looking into that.
~ No More Love ~
2008-12-21 16:36:01 UTC
I think its belong to the time of your server


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...