我尝试使用我的 cron php 脚本创建电子邮件以供下次发送。我使用 Zend_View 来呈现电子邮件模板。我有 50k 用户,但创建了 3000 封电子邮件,内存限制为 64MB,7200 封电子邮件限制为 128MB。呈现电子邮件的代码
public function prepareEmailBody($template, $templates)
{
$view = new Zend_View(array('basePath' => './application/views'));
$template_file_name = $template . '.phtml';
foreach ($templates as $key => $value) {
$view->$key = $value;
}
$body = $view->render('mails/' . $template_file_name);
return $body
}
并在
foreach ($users as $user) {
.....
$text = Mailer::getInstance()->prepareEmailBody($template, $vars);
.....
}
请建议如何优化代码。