Questions | Login

Top / PHP

The time is wrong on my emails sent by php sendmail script?

demo 21 Dec 2008 08:14am
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
Just a reminder, I am using an older version of PHP that apparently does NOT allow you to set the timezone.

Answers

demo 21 Dec 2008 08:24am
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.
demo 21 Dec 2008 08:36am
I think its belong to the time of your server
demo 21 Dec 2008 09:13am
Add the datetime you want to use as an additional header.

<?php
date_default_timezone_set( "America/New_York" );
$now = new DateTime();

$to = "you@you.com";
$header = "From: me@me.comrnDate: " . date_format($now, 'r');
$subject = "foobar";
$body = "hello world";

mail( $to, $subject, $body, $header );
?>
demo 22 Dec 2008 07:08am
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.
demo 24 Dec 2008 12:25am
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/

Related

Submit Answer

You must be logged in to post an answer. Please Login or Register.

Powered by phpMyAnswers.