Speed issues

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
gcaplan
Forum Newbie
Posts: 2
Joined: Thu Apr 16, 2009 7:37 am

Speed issues

Post 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
gcaplan
Forum Newbie
Posts: 2
Joined: Thu Apr 16, 2009 7:37 am

Re: Speed issues

Post 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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Speed issues

Post 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).
Post Reply