Author |
|
Jonathonq Newbie
Joined: 15 February 2010 Location: New Zealand
Online Status: Offline Posts: 3
|
Posted: 15 February 2010 at 12:58pm | IP Logged
|
|
|
Hi there
We are using the MailBee.Net POP3 and IMAP components to download emails from an email server expecting them to be acknowledgments for emails previously sent from this account.
First off I've implemented this by
a) Reconnecting to a POP3 server every 5 seconds and using DownloadMessageHeaders(1, m_client.InboxMessageCount, 100) to retrieve any messages before deleting them.
b) Calling DownloadEnvelopes("1:*", true, MailBee.ImapMail.EnvelopeParts.MessagePreview, 4096) every 5 seconds to the IMAP server to retrieve any messages before deleting them.
The software will be used by a variety of customers with different Email Servers. Thus I've tried to avoid doing any thing that is not commonly supported so it will work with as many servers as possible. We will probably make the 5 second timeout configurable as some customers may outsource their email. Is there a better way of actively recieving email as quickly as it is received on the server?
I tried IDLE with IMAP but that isn't supported by our domino server.
POP3 connections need to be closed to permanently delete emails from the server but can a connection be kept open as long as no emails are present? (eg only reconnected when we need to delete)
I am only downloading a preview of the body as we do not want excessively large emails inhibiting the performance of our software (it is a security system). We only log the first 1k of body plain text and discard attachments. Is there any thing else we should do to safe guard the software?
Thanks
Jonathon Quinn
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6103
|
Posted: 16 February 2010 at 3:06am | IP Logged
|
|
|
When mail client connects to POP3 server, it obtains a snapshot of account inbox. You will not be able to retrieve the info about any new incoming messages without reconnecting to POP3 server. In IMAP case, IDLE is not the only approach possible, you can use polling there based on seen/unseen flag. The following Knowledge Base article should be helpful in this regard:
Getting notifications about new messages in mailbox (IMAP IDLE and polling)
In case if your system does not require full message body or attachments, downloading first 1Kb of plaintext body seems to be the optimal approach. If you need to protect your system from spam and other sorts of malicious mails, using Antispam component may be a good idea.
--
Regards,
Igor, AfterLogic Support
|
Back to Top |
|
|
Jonathonq Newbie
Joined: 15 February 2010 Location: New Zealand
Online Status: Offline Posts: 3
|
Posted: 16 February 2010 at 3:51pm | IP Logged
|
|
|
Thanks heap Igor
Our system is actually clearing the inbox once all emails have been downloaded so the seen/unseen flags really useful. We just need to know when the inbox is not empty.
I'm checking the Inbox count is greater than zero after making a POP3 connection to avoid an unnecessary downloadheaders call. In the IMAP case I assume there would be minimal traffic when the inbox is empty with just a downloadenvelopes call.
Do you have any suggestions for polling periods ? I'm thinking a couple of options from 5 seconds to 5 minutes.
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6103
|
Posted: 17 February 2010 at 3:59am | IP Logged
|
|
|
I think those periods depend on average server load generated by retrieving new mails and thus should be picked experimentally. I would start with 60 seconds and calculate next polling period start from previous session end, in case if retrieving mails takes more than a minute.
--
Regards,
Igor, AfterLogic Support
|
Back to Top |
|
|
Jonathonq Newbie
Joined: 15 February 2010 Location: New Zealand
Online Status: Offline Posts: 3
|
Posted: 17 February 2010 at 12:43pm | IP Logged
|
|
|
hmmm, we are only expecting a trickle of messages. 99% of the time there will be none to download but we do want to able respond as quickly as possible to any new messages (within seconds).
But some customers will be outsourcing their email or possibly the Email server will not be happy with quick multiple reconnects so there will be options to reduce it.
|
Back to Top |
|
|