473,734 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with Date in Email Header

Hello,

when I send an email using the mail() function, I get a Runtime Notice:

date() [function.date]: It is not safe to rely on the system's timezone
settings. Please use the date.timezone setting, the TZ environment variable
or the date_default_ti mezone_set() function. In case you used any of those
methods and you are still getting this warning, you most likely misspelled
the timezone identifier. We selected 'Europe/Paris' for '2.0/DST' instead.

I found out that this is caused by the date-part in the header. But I can't
find what's wrong with it.

I hope you can help me out!

Thanks,
Ramon.
This is a snippet of my script:

$sBoundary = md5(mt_rand());
$sHeaders = "Date: $sTimestamp\n" .
"From: $sMailFrom\r\n" .
"Reply-To: " . $GLOBALS ["Email"]["ReplyToAddress "]
.. "\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: multipart/alternative; ".
"boundary=$sBou ndary\r\n\r\n" .
"This is a multi-part message in MIME
format.\r\n\r\n ";

$sBody = "--$sBoundary\n" .
"Content-Type: text/plain;
charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$this->m_sTextBody . "\n\n" .
"--$sBoundary\n" .
"Content-Type: text/html; charset=\"iso-8859-1\"\n"
..
"Content-Transfer-Encoding: 7bit\n\n" .
$this->m_sHTMLBody . "\n\n" .
"--$sBoundary--";

$this->m_bSendResul t = mail($this->m_sToMail, $this->m_sSubject,
$sBody, $sHeaders);
And this is the ouput:

Date: Fri, 18 Aug 2006 19:06:00 +0200
From: John Doe <jo**@doe.com >
Reply-To: jo**@doe.com
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary=4ecaa2 21dc319a2ce4905 365efe5e550

This is a multi-part message in MIME format.

--4ecaa221dc319a2 ce4905365efe5e5 50
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

This is some plain text.

--4ecaa221dc319a2 ce4905365efe5e5 50
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

<html><body><b> This is some <i>HTML</itext.</b></body></html>

--4ecaa221dc319a2 ce4905365efe5e5 50--
Aug 18 '06 #1
7 14128
*** Ramon escribió/wrote (Fri, 18 Aug 2006 19:20:38 +0200):
date() [function.date]: It is not safe to rely on the system's timezone
settings. Please use the date.timezone setting, the TZ environment variable
or the date_default_ti mezone_set() function. In case you used any of those
methods and you are still getting this warning, you most likely misspelled
the timezone identifier. We selected 'Europe/Paris' for '2.0/DST' instead.

I found out that this is caused by the date-part in the header. But I can't
find what's wrong with it.
Where do you call date()? I can't find it in your code :-? The $sTimestamp
variable is already there...

Also, I'm curious about why you need to specify a "Date" header.

--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Aug 18 '06 #2
Hello Alvaro,

The variable was outside the piece of code:
$sTimestamp = date("r");

I do this because otherwise I get the error message I wrote. I tested it by
copying a date from an email I sent with Outlook Express. Using that (hard
coded) date, it worked fine. But when I use the Timestamp variable (which
uses the same notation), it doesn't work. So I think I'm missing something
here, but I can't find out what...
Ramon.

"Alvaro G. Vicario" <we*******@NOSP AMdemogracia.co mwrote in message
news:4o******** *************** ******@40tude.n et...
*** Ramon escribió/wrote (Fri, 18 Aug 2006 19:20:38 +0200):
>date() [function.date]: It is not safe to rely on the system's timezone
settings. Please use the date.timezone setting, the TZ environment
variable
or the date_default_ti mezone_set() function. In case you used any of
those
methods and you are still getting this warning, you most likely
misspelled
the timezone identifier. We selected 'Europe/Paris' for '2.0/DST'
instead.

I found out that this is caused by the date-part in the header. But I
can't
find what's wrong with it.

Where do you call date()? I can't find it in your code :-? The $sTimestamp
variable is already there...

Also, I'm curious about why you need to specify a "Date" header.

--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--

Aug 18 '06 #3
*** Ramon escribió/wrote (Fri, 18 Aug 2006 20:36:33 +0200):
The variable was outside the piece of code:
$sTimestamp = date("r");

I do this because otherwise I get the error message I wrote.
You don't need to specify date headers, sendmail or whatever software
performs the actual delivery takes care about such details.

Do you get the same error message with, let's say, a one-liner sample code?
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Aug 18 '06 #4
By sending a mail just with: mail(xx*@yyy.zz z, "test mail"), it goes fine.
But I need to send a html-mail, and then you have to specify the headers.
I have to use the php "mail()" function because I can't install additional
software on the server.

"Alvaro G. Vicario" <we*******@NOSP AMdemogracia.co mwrote in message
news:18******** *************** ******@40tude.n et...
*** Ramon escribió/wrote (Fri, 18 Aug 2006 20:36:33 +0200):
>The variable was outside the piece of code:
$sTimestamp = date("r");

I do this because otherwise I get the error message I wrote.

You don't need to specify date headers, sendmail or whatever software
performs the actual delivery takes care about such details.

Do you get the same error message with, let's say, a one-liner sample
code?
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--

Aug 18 '06 #5
*** Ramon escribió/wrote (Fri, 18 Aug 2006 21:02:18 +0200):
By sending a mail just with: mail(xx*@yyy.zz z, "test mail"), it goes fine.
But I need to send a html-mail, and then you have to specify the headers.
Yes, but not *all* headers, only additional ones.

Sorry, I'm lost. I can't figure our where that error message comes from. It
doesn't have the typical format of PHP messages... BTW, I presume you
followed its instructions and didn't work, didn't your?
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Aug 18 '06 #6
Guess what,
I found the problem in the PHP documentation:

"Since PHP 5.1.0 (when the date/time functions were rewritten), every call
to a date/time function will generate a E_NOTICE if the timezone isn't
valid, and/or a E_STRICT message if using the system settings or the TZ
environment variable."

So, I added the function: date_default_ti mezone_set ("Europe/Amsterdam");
and the problems were gone...

Thanks Alvaro,
for your efforts!

"Alvaro G. Vicario" <we*******@NOSP AMdemogracia.co mwrote in message
news:jq******** *************** *****@40tude.ne t...
*** Ramon escribió/wrote (Fri, 18 Aug 2006 21:02:18 +0200):
>By sending a mail just with: mail(xx*@yyy.zz z, "test mail"), it goes
fine.
But I need to send a html-mail, and then you have to specify the headers.

Yes, but not *all* headers, only additional ones.

Sorry, I'm lost. I can't figure our where that error message comes from.
It
doesn't have the typical format of PHP messages... BTW, I presume you
followed its instructions and didn't work, didn't your?
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--

Aug 18 '06 #7
You don't have to set the date to send an HTML email. Just specify the
headers that you want to change, and let sendmail handle the others(like
Date).

-Steven

Ramon wrote:
Guess what,
I found the problem in the PHP documentation:

"Since PHP 5.1.0 (when the date/time functions were rewritten), every call
to a date/time function will generate a E_NOTICE if the timezone isn't
valid, and/or a E_STRICT message if using the system settings or the TZ
environment variable."

So, I added the function: date_default_ti mezone_set ("Europe/Amsterdam");
and the problems were gone...

Thanks Alvaro,
for your efforts!

"Alvaro G. Vicario" <we*******@NOSP AMdemogracia.co mwrote in message
news:jq******** *************** *****@40tude.ne t...
>*** Ramon escribió/wrote (Fri, 18 Aug 2006 21:02:18 +0200):
>>By sending a mail just with: mail(xx*@yyy.zz z, "test mail"), it goes
fine.
But I need to send a html-mail, and then you have to specify the headers.
Yes, but not *all* headers, only additional ones.

Sorry, I'm lost. I can't figure our where that error message comes from.
It
doesn't have the typical format of PHP messages... BTW, I presume you
followed its instructions and didn't work, didn't your?
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--

Aug 19 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5919
by: Marauderz | last post by:
Hello guys, got a little question regarding the regional language settings . Anyway I got a Windows 2003 Server machine that was installed with the date format "dd/MM/yyyy" and location still locked in US. As we migrated certain apps over to the new machine. we found out something... someone coded a Now.ToString in a database query... and the SQL Box is running MM/dd/yyyy! Chaos follows!!! I tried setting the Administrator account's...
5
9149
by: Tim_Mac | last post by:
hi, i read that by adding the following code to by aspx pages, it would not store temporary internet files: Response.Cache.SetCacheability(HttpCacheability.NoCache); it didn't actually work that way, but i left it in anyway. little did i know it would cause a problem for a forced download routine i have. instead of downloading the .xls attachment, it tried to download the aspx file, and gave an error saying the file could not be...
0
2539
by: Rafal Zawadzki | last post by:
Hi. I tried earlier to write python zsi mail list, but nobody answered. I am using ZSI 1.7/2.0rc1 with TTPro Soap SDK. The wsdl file can be found here: http://demo.seapine.com/ttsoapcgi.wsdl My wsdl is the same, only different is the address of the cgi file. for example i cannot use defectRequest method:
102
6805
by: hug | last post by:
www.webmaster, was suggested that this ng could be a better place.] I've updated my test server to handle if-modified-since. I've noticed that the (old copies I run of) IE and Netscape seem never to send if-modified-since. But the strange thing is that Opera sends if-modified-since but when I reply with "HTTP/1.0 304 Not Modified" it is not refreshing the screen from its cache, it is leaving the screen blank.
2
2958
by: DC | last post by:
The Code <%@ import namespace="System" %> <%@ import namespace="System.Web" %> <%@ import namespace="System.Web.UI" %> <%@ import namespace="System.Web.UI.HtmlControls" %> <%@ import namespace="System.Web.UI.WebControls" %> <%@ import namespace="System.Data" %> <%@ import namespace="System.Data.OleDb" %>
0
1632
by: Nico Grubert | last post by:
Hi there, I wrote a short python script that sends an email using python's email module and I am using Python 2.3.5. The problem is, that umlauts are not displayed properly in some email clients: + On a windows machine running thunderbird 1.0.2 umlauts are displayed properly. The email header contains "Content-type: text/plain; charset=utf-8"
7
4826
by: Kamal | last post by:
Hello all, I have a very simple html table with collapsible rows and sorting capabilities. The collapsible row is hidden with css rule (display:none). When one clicks in the left of the expandable row, the hidden row is made visible with css. The problem is when i sort the rows, the hidden rows get sorted as well which i don't want and want to be moved (while sorting) relative to their parent rows. The following is my complete html code...
2
3013
by: swethak | last post by:
hi , i write the code in .htm file. It is in cgi-bin/searches/one.htm.In that i write a form submitting and validations.But validations are not worked in that .htm file. I used the same code in my local system that validations work.plz tell that whats the problem in that. Here is my code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html...
11
5017
by: jessy | last post by:
Hi, I have a problem with my DateTimePicker javascript code which i downloaded , the problem is when i pick the date and the date appears in my Text Field and i click Submit the date which i picked is not sent to the DB and instead the default value of the text field which is 00-00-0000 is Sent so what i need is to make the value i picked replace the value of the Text Field and i cant seem to get the Js code which i downloaded . i'm...
0
8956
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8783
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9459
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9248
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9191
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4819
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3267
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2735
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.