所有人都可以訪問所需的資源來訪問給定的網址即通訊/發送。不要緊,如果真正的人打的網址,因爲該網頁的內容將是相當無趣=)
該腳本本身只會檢查是否有郵件發送,然後從數據庫中抓住所有用戶等通訊方法對Zend來說非常不可靠。
雖然你可以很容易地用Zend和Zend_Mail做模板。這是我在如何處理的Zend電子郵件:
$mail = new Zend_Mail('UTF-8');
$mailView = new Zend_View();
$mailView->setScriptPath(APPLICATION_PATH.'/views/email/');
$mailView->assign('title', $this->_report->getTitle());
$mailView->assign('text', $this->_report->getText());
$mail->addTo($user->getEmail(), $user->getFullnameBySurname());
$mail->setBodyHtml($mailView->render('emailregular.phtml')); // /application/views/email/emailregular.phtml
$mail->setBodyText(strip_tags($mailView->render('emailregular.phtml'))); //might not be the cleanest way...
try {
$mail->send();
$mail->clearRecipients(); // This clears the addTo() for Zend_Mail as in my script i only have one instance of zend_mail open while looping through several users
$this->_log->info('Mail out for user ....');
} catch (Zend_Mail_Transport_Exception $e) {
$this->_log->error('Zend_Mail_Transport_Exception for User('.$user->getid().') - Mails were not accepted for sending: '.$e->getMessage());
} catch (Zend_Mail_Protocol_Exception $e) {
$this->_log->error('Zend_Mail_Protocol_Exception for User('.$user->getid().') - SMTP Sentmail Error: '.$e->getMessage());
} catch (Exception $e) {
$this->_log->error('Unknown Exception for User('.$user->getid().') - SMTP Sentmail Error: '.$e->getMessage());
}
希望這是什麼youre要求=)
來源
2012-06-18 05:18:30
Sam
非常感謝mate.exactly我是什麼擔心 –