Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Mail::IMAPClient Time Zone

by shibu_pu (Acolyte)
on Mar 13, 2009 at 13:15 UTC ( [id://750404]=perlquestion: print w/replies, xml ) Need Help??

shibu_pu has asked for the wisdom of the Perl Monks concerning the following question:

I am using the CPAN module "Mail::IMAPClient" for getting the mail counts on a specified date.

I am using the 'on' function to get the number of mails for the below three sample dates, and printing the resulted mails' date header.

@on = $imap->on('10-Mar-2009')
Tue, 10 Mar 2009 10:00:42 -0800
Tue, 10 Mar 2009 19:33:19 -0400 (EDT)

@on = $imap->on('11-Mar-2009')
Wed, 11 Mar 2009 17:02:53 +0000
Wed, 11 Mar 2009 17:47:45 -0700

@on = $imap->on('12-Mar-2009')
Wed, 11 Mar 2009 21:55:08 -0700 (PDT)
Wed, 11 Mar 2009 22:02:42 -0700 (PDT)
Thu, 12 Mar 2009 14:18:43 -0700
Thu, 12 Mar 2009 19:05:31 -0700

But for the date '11-Mar-2009', actually there are 4 mails on that date. But it is showing 2 mails for that date and the other 2 showing in the next date '12-Mar-2009'. I think its because of its different time zone. Is there any way to get the mails in the actual date itself regardless of the time zone.

Replies are listed 'Best First'.
Re: Mail::IMAPClient Time Zone
by tirwhan (Abbot) on Mar 13, 2009 at 14:03 UTC

    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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://750404]
Approved by gwadej
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-03-28 18:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found