SMTP seems very slow. Each time someone sends a message to my auto email program, I need to send out two emails and maybe more. One email is to the sender to give them whatever response is appropriate. The other that is always sent is the log email sent to some administrator email address. Sometimes, the sender requests a broadcast and then all registered users get an email.

I did some research and it is certainly the case that spammers use special email tools to get their point across as quickly as possible. I do not condone spam, ever. Many sites had discussions about how to send multiple emails at the same time and there was no mention of SMTP servers rejecting multiple simultaneous requests from the same client system.

So I went ahead and added code to handle multiple outgoing email queues and multiple threads to handle those queues. The code is set up so that each important item, such as the queue or the connection object, are arrays of those objects. The array length is a constant and all of the code is set up to handle any number of outgoing email queues and threads.

The one thing that I could have done that I didn’t end up doing is any sort of load balancing. The function that is called to queue an email uses each queue in order. It does not check to see which queue is least full.

This worked great. Sending two emails takes the time it had taken to send one.