I am trying to send an email from a C++ program using imap library. I have a Google Apps and a Gmail account to which I am sending the email.
Whenever the program fail
The library uses some ancient I/O multiplexing code and as a result it can only handle 1,024 connections at a time. Either use a different library or rate-limit your requests to the library.
Update: I was going to research this for you and, if necessary, fix the code to work around this or figure out changes to how you build the code. But it seems the library is not publicly available. Sorry, we can't fix closed source code for you.