0

I have a script which processes data relating to the previous provided by an e-mail which arrives everyday at 00:30. So the data for the 30th March 2019 would be sent at 00:30 on 31st March. I extract the e-mails using the following code in Python 2.7

server = imaplib.IMAP4_SSL(HOST)
server.login(USERNAME, PASSWORD)
server.select('INBOX'
rv, data = server.search(None,'FROM', From, 'SUBJECT', Subject,'SENTSINCE', from_date)

The code ran perfectly for 3 months until the move to British Summer Time (I am based in the UK). Checking the data, the mail was seen by imap as received at 23:30 on 30th March instead of 00:30 on 31st March. My SENTSINCE was 31-Mar-2019 and imap was not returning any message.

My timezone is GMT standard time, and when I use datetime, I get the correct time adjusted for daylight savings. My question is how can I set the timezone so that imaplib interpretes the time correctly?

Pascal
  • 1
  • 1
  • Code line `server.select('INBOX'` seems to be incomplete. – Heikki Apr 01 '19 at 10:06
  • What does the RFC say about timezones? – snakecharmerb Apr 01 '19 at 21:37
  • The IMAP RFC says nothing about timezones, therefore the interpretation is up to the server, and there is no way for a client to control it. Many servers work in local time, many in UTC, etc. Adapt your query as necessary for your server. – Max Apr 02 '19 at 14:05

0 Answers0