Mail::IMAPClients "on" function has very little to do with the Date header inside the emails. "on" uses the IMAP "ON" search argument, which searches for messages by the internal date, i.e. the time at which it was received by the server. To list messages by the date they were sent (which is what the Date: header specifies) you'll need to search using "senton".

I don't think this will solve the problem you're having though, because, from a quick skim through the code, Mail::IMAPClient won't let you specify a timezone in these methods. To do that, you need to manually construct an IMAP SEARCH (using the "search method) including a SENTON argument. Read RFC 2060 on the exact syntax for that.

Update: Reading up the relevant RFCs, I find that what I wrote in the stricken-out section is wrong. IMAP4rev1 does not permit inclusion of time or time zone in ON and SENTON searches (this is clarified in RFC 3501). So searching with these methods will always only take into account the date section of the relevant entry (either "Date:" or "internal date"). It seems what you want cannot be done with IMAP and you need to sort mail client-side (though formally, SENTON will retrieve all mails with the Date: header of a certain day, this is just completely irrespective of your clients time zone).


All dogma is stupid.

In reply to Re: Mail::IMAPClient Time Zone by tirwhan
in thread Mail::IMAPClient Time Zone by shibu_pu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.