What sort of speed should I expect from using Zend_Mail_Transport_Smtp with Gmail?

2 messages Options
Embed this post
Permalink
Andrew Havens

What sort of speed should I expect from using Zend_Mail_Transport_Smtp with Gmail?

Reply Threaded More More options
Print post
Permalink
I have a script that sends an email out to a list of subscribers, but
it runs _really_ slow, especially for how few subscribers I am testing
against. Within the foreach loop, it takes about 3-5 seconds per
email.

My code looks something like this:

$config = array('ssl' => 'tls', 'port' => 587, 'auth' => 'login',
'username' => 'username', 'password' => 'password');
$smtpConnection = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
Zend_Mail::setDefaultTransport($smtpConnection);

$attachment = new Zend_Mime_Part(file_get_contents($filepath));
$attachment->type = 'application/pdf';
$attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
$attachment->encoding = Zend_Mime::ENCODING_BASE64;
$attachment->filename = $filename;

foreach ($subscribers as $subscriber) {
    $message = new Zend_Mail('utf-8');
    $message->setFrom('[hidden email]', 'From Name')
        ->addTo($subscriber->email)
        ->setSubject($subject)
        ->setBodyText($body);
    $message->addAttachment($attachment);
    $message->send();
}

Is there something that I should be doing differently?
weierophinney

Re: What sort of speed should I expect from using Zend_Mail_Transport_Smtp with Gmail?

Reply Threaded More More options
Print post
Permalink
-- Andrew Havens <[hidden email]> wrote
(on Friday, 24 April 2009, 04:16 AM -0700):
> I have a script that sends an email out to a list of subscribers, but
> it runs _really_ slow, especially for how few subscribers I am testing
> against. Within the foreach loop, it takes about 3-5 seconds per
> email.

Have you tested using a local SMTP server or sendmail? My suspicion is
that the delay is due to network latency.

> My code looks something like this:
>
> $config = array('ssl' => 'tls', 'port' => 587, 'auth' => 'login',
> 'username' => 'username', 'password' => 'password');
> $smtpConnection = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
> Zend_Mail::setDefaultTransport($smtpConnection);
>
> $attachment = new Zend_Mime_Part(file_get_contents($filepath));
> $attachment->type = 'application/pdf';
> $attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
> $attachment->encoding = Zend_Mime::ENCODING_BASE64;
> $attachment->filename = $filename;
>
> foreach ($subscribers as $subscriber) {
>     $message = new Zend_Mail('utf-8');
>     $message->setFrom('[hidden email]', 'From Name')
>         ->addTo($subscriber->email)
>         ->setSubject($subject)
>         ->setBodyText($body);
>     $message->addAttachment($attachment);
>     $message->send();
> }
>
> Is there something that I should be doing differently?
>

--
Matthew Weier O'Phinney
Project Lead            | [hidden email]
Zend Framework          | http://framework.zend.com/