I just wrote a set of bulk-emailing classes for handling enormous amounts of emails and parsing their content according to passed params. If I test an email on 1000 random recipients and 1000 random senders from my database, up until the point the script hits the send() part (I commented it for now), I get performance of around 2 seconds, and 20 MB peak memory, which is great.
However, if I uncomment the send part, the sending takes 30 seconds. This is unacceptable, and I would like to speed it up somehow. It is obvious from testing that the delay is caused by none other than the $mail->send() call, as if it's waiting for it to return something before continuing the loop and sending the next email.
What I'm wondering is: how do I speed up the send() call? What can I do to make it faster? I tried using two sending methods:
- Zend SMTP transport, connecting to the server directly and just sending. This takes 30 seconds per 1000 emails.
- Sendmail via Zend_Mail. Simply calling Zend_Mail's send function after preparing each email. This takes 60 seconds.
Please note that queueing is definitely an option, and I have built it into my classes. All it takes is activating a cron and it works like a charm. But I'm wondering about the actual sending and how to speed that up. So, the actual send() call.