Zend_Mail::clearRecipients PHP Method

clearRecipients() public method

Clears list of recipient email addresses
public clearRecipients ( ) : Zend_Mail
return Zend_Mail Provides fluent interface
    public function clearRecipients()
    {
        $this->_recipients = array();
        $this->_to = array();
        $this->clearHeader('To');
        $this->clearHeader('Cc');
        $this->clearHeader('Bcc');
        return $this;
    }

Usage Example

Beispiel #1
0
 /**
  * TOAN LE
  * (non-PHPdoc)
  * @see App_Service_Cron_Interface::run()
  */
 public function run()
 {
     if ($this->_data['run']) {
         $view = new Zend_View();
         $view->setScriptPath(PATH_TEMPLATE . DS . 'mailer' . DS . 'cron' . DS);
         /*****/
         $userModel = new Model_Users();
         $adapter = $userModel->getMapper()->getDbTable()->getAdapter();
         $select = $adapter->select();
         $select->from(array('xm_users'), array('*'));
         $select->where("username RLIKE '[^a-zA-Z0-9()_.@\\-]'");
         $result = $adapter->fetchAll($select);
         foreach ($result as $res) {
             try {
                 $view->datas = $res;
                 $body = $view->render('rename_username_unicode.phtml');
                 $smtp = new Zend_Mail('UTF-8');
                 $smtp->clearRecipients();
                 $smtp->setBodyHtml($body);
                 $smtp->addTo($res['email'], $res['username']);
                 //if (file_exists($filename)) {
                 //$attachment = file_get_contents($filename);
                 //$smtp->createAttachment($attachment, 'application/octet-stream', 'attachment', 'base64', $report['fileName']);
                 //unlink($filename);// after done, remove file in server
                 //}
                 $smtp->setSubject('Thong bao thay doi tai khoan');
                 $smtp->send();
                 $message = "Sent mail success to \n";
                 $message .= "Params: \n" . var_export($res, true) . "\n";
                 $message .= "-------------------------------\n\n\n";
             } catch (Zend_Exception $exception) {
                 $message = $exception->getMessage() . "\n" . $exception->getTraceAsString() . "\n\nParams: \n" . var_export($res, true) . "\n";
                 $message .= "-------------------------------\n\n\n";
             }
             if (Zend_Registry::isRegistered('logger')) {
                 $logger = Zend_Registry::get('logger');
             }
             $logger->log($message, Zend_Log::DEBUG);
         }
     }
 }
All Usage Examples Of Zend_Mail::clearRecipients