Page 1 of 1

Speed issues

Posted: Thu Apr 16, 2009 8:28 am
by gcaplan
Hi folks

I've got a script that uses Swift to send out a number of emails to customers. Each email is different, so I can't use cc or bcc.

The problem is, I can't find a way to get the dispatch time for each email to under a couple of seconds. Because there are a lot of emails, and the script is called via a web request, there are issues with keeping the request running long enough without timing out, so I'm looking to speed things up.

By default, we're using the SMTP server of our mail host: this is slow, even though they are a top-class host.

I also tried using a local mail transport on our linux server, but to my surprise, this was no faster. Perhaps because shelling out of PHP is so slow? Ditto with using the mail transport. So each transport is giving me similar, slow results.

I'd welcome any ideas about how to speed up sending mails from php, using Swift or by some other method.

Geoff

Re: Speed issues

Posted: Fri Apr 17, 2009 10:01 am
by gcaplan
Hi folks

Mea culpa...

Turns out I'd misunderstood the capabilities of our sendmail replacement null mailer - it didn't have a queue and was sending mails one at a time, just like the Swift SMTP transport, which explains the similar timings.

With a bit of a struggle, got Postfix working. Processing time in the script has dropped from average 4s to average 0.04 secs.

Solves the problem, I think!

Geoff

Re: Speed issues

Posted: Sun Apr 19, 2009 11:04 pm
by Chris Corbyn
Another optimization in version 4 (at this point in time):

Code: Select all

$message->setEncoder(Swift_Encoding::get8BitEncoding());
This avoids the *massive* overhead of QP encoding.

It will happen implicitly soon, provided the server informs Swift Mailer it can handle 8 bit encodings (it's an SMTP feature that most servers supports these days).