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('email@gmail.com', 'From Name')
->addTo($subscriber->email)
->setSubject($subject)
->setBodyText($body);
$message->addAttachment($attachment);
$message->send();
}
Is there something that I should be doing differently?
没有评论:
发表评论