0

While working with JavaMail API, I used below two properties to create a session and then to download emails from server. This (setting below properties) will cause data to be fetched from the server in larger chunks and hence to download large message bodies efficiently. I am looking for similar option in python so that data to be fetched from the server should be in larger chunks. Can someone help me achieve this in Python?.

       props.setProperty("mail.imaps.partialfetch","true");
       props.setProperty("mail.imaps.fetchsize", "2000000");
user3656231
  • 431
  • 2
  • 7
  • 17
  • what library are you using for python? – Tadhg McDonald-Jensen Jul 20 '20 at 13:20
  • Using these - import email , import imaplib – user3656231 Jul 20 '20 at 13:21
  • you probably just need to [set the socket buffer size](https://stackoverflow.com/questions/30888397/how-to-set-send-buffer-size-for-sockets-in-python) since `imaplib` uses sockets to send and receive. I'm not confident enough in that to post a proper answer though. How would you even detect the difference for this kind of performance change? – Tadhg McDonald-Jensen Jul 20 '20 at 13:37
  • I compared the time taken to download an email of particular size to check the performance. Increasing fetch size in java takes less time. – user3656231 Jul 20 '20 at 14:04
  • @ Tadhg McDonald-Jensen , So is it possible to pass socket buffer size to the imaplib so that the library can pick the user specified buffer size? – user3656231 Jul 20 '20 at 14:29
  • I just tested with a 40MB email (including attachments). Using Java (setting a fetch size of 4MB) it took less than one minute. but my python code [mail.search(None,'(FLAGGED)') ] could not download and it got timed out. – user3656231 Jul 20 '20 at 14:48

0 Answers0