Problem with Date in Email Header

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ramon

    #1

    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 <john@doe.com >
    Reply-To: john@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--


  • Alvaro G. Vicario

    #2
    Re: Problem with Date in Email Header

    *** 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
    --

    Comment

    • Ramon

      #3
      Re: Problem with Date in Email Header

      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" <webmaster@NOSP AMdemogracia.co mwrote in message
      news:4oxvx6x6es 39$.1t1l45xsw5c hj.dlg@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
      --

      Comment

      • Alvaro G. Vicario

        #4
        Re: Problem with Date in Email Header

        *** 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
        --

        Comment

        • Ramon

          #5
          Re: Problem with Date in Email Header

          By sending a mail just with: mail(xxx@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" <webmaster@NOSP AMdemogracia.co mwrote in message
          news:18dlyab03g dg8$.5ec8b0qk27 j2.dlg@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
          --

          Comment

          • Alvaro G. Vicario

            #6
            Re: Problem with Date in Email Header

            *** Ramon escribió/wrote (Fri, 18 Aug 2006 21:02:18 +0200):
            By sending a mail just with: mail(xxx@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
            --

            Comment

            • Ramon

              #7
              Re: Problem with Date in Email Header

              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" <webmaster@NOSP AMdemogracia.co mwrote in message
              news:jqmono3yoc 8j.1r47xyv0a2dv 5.dlg@40tude.ne t...
              *** Ramon escribió/wrote (Fri, 18 Aug 2006 21:02:18 +0200):
              >By sending a mail just with: mail(xxx@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
              --

              Comment

              • Steven Musumeche

                #8
                Re: Problem with Date in Email Header

                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" <webmaster@NOSP AMdemogracia.co mwrote in message
                news:jqmono3yoc 8j.1r47xyv0a2dv 5.dlg@40tude.ne t...
                >*** Ramon escribió/wrote (Fri, 18 Aug 2006 21:02:18 +0200):
                >>By sending a mail just with: mail(xxx@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
                >--
                >
                >

                Comment

                Working...