Javamail performance

后端 未结 4 1423
南笙
南笙 2021-01-06 02:58

I\'ve been using javamail to retrieve mails from IMAP server (currently GMail). Javamail retrieves list of messages (only ids) in a particular folder from server very fast,

相关标签:
4条回答
  • 2021-01-06 03:25

    I'm not sure if this is a Javamail issue as much as it may be a Gmail issue. I have an application that retrieves mail from a number of sources, including Gmail, and Gmail is definitely the slowest. The Javamail api is pretty straightforward, but it would be hard to make suggestions without seeing what you are currently doing.

    0 讨论(0)
  • 2021-01-06 03:27

    I'm running into the same thing. After profiling, I noticed that getBody was being called every time I tried to do a message.getFrom() like you are, even though I was only accessing fields that should be covered by the Envelope flag. See https://java.net/projects/javamail/forums/forum/topics/107956-gimap-efficiency-when-only-reading-headers

    0 讨论(0)
  • 2021-01-06 03:29

    I believe that Gmail throttles the IMAP message reads to one every second or so. You might be able to speed it up with multiple IMAP connections.

    0 讨论(0)
  • 2021-01-06 03:39

    Please set the Property mail.imap.fetchsize with the required size. the default is 16k. In case you increase the size of this property, retrieve speed will go up.

    props.put("mail.imap.fetchsize", "3000000");

    Note that if you're using the "imaps" protocol to access IMAP over SSL, all the properties would be named "mail.imaps.*".

    Good Luck.

    Yaniv

    0 讨论(0)
提交回复
热议问题