« Return to Thread: What sort of speed should I expect from using Zend_Mail_Transport_Smtp with Gmail?

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

by weierophinney :: Rate this Message:

Reply to Author | View in Thread

-- Andrew Havens <misbehavens@...> 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('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            | matthew@...
Zend Framework          | http://framework.zend.com/

 « Return to Thread: What sort of speed should I expect from using Zend_Mail_Transport_Smtp with Gmail?