I am using two email templates and tested performance:
- 100 emails with 25 products per email took 24 seconds.
- 100 emails with 12 products per email took 16 seconds.
All images (e.g. logos, banners, products) are text that invoke URLs where images are hosted on the server).
I feel that the increase in time (from 16 to 24 seconds just for 100 emails) is dramatic, considering that I am only adding a few KB per product. If this is happening only sending 100 emails, the impact sending thousands of emails in terms or time and performance to complete the sends would be high. My code uses this:
....
require_once "/.../ea-php70/root/usr/share/pear/Mail.php";
$params['sendmail_path'] = '/usr/lib/sendmail';
$mail_object =& Mail::factory('sendmail', $params);
$timeoutSet = set_time_limit(18000); // set script time out to 5 hours
...
for ($i = 1; $i <= 100; $i++) {
...
$_mail = $mail_object->send($recipients, $headers, $sendContent);
....
}
....
How can I make my PEAR::Mail implementation faster for sending bulk emails? I am suspecting that maybe my server is throttling emails or that I need to change some PEAR::Mail settings, or maybe use SMTP instead of Sendmail. Any ideas? Thank you.
UPDATE 1:
I have an 8 core, 16 thread processor. One thing I have done is to run my script in parallel from different tabs of the web browser so that for example instead of taking 4 minutes for sending 8000 emails, it only takes 1 minute because I send them in 4 batches of 2000 emails each, running the script simultaneously in 4 parallel and independent processes. I am trying to find other ways to expedite even more this CPU intensive task and I am wondering if PEAR::Mail
has some settings that I can modify to send emails faster.