当前位置: 首页>>代码示例>>PHP>>正文


PHP EmailMessage::addBcc方法代码示例

本文整理汇总了PHP中EmailMessage::addBcc方法的典型用法代码示例。如果您正苦于以下问题:PHP EmailMessage::addBcc方法的具体用法?PHP EmailMessage::addBcc怎么用?PHP EmailMessage::addBcc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EmailMessage的用法示例。


在下文中一共展示了EmailMessage::addBcc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: perform

 function perform()
 {
     // extract the data
     $recipients = $this->_request->getValue("messageRecipient");
     $recipientsCc = $this->_request->getValue("messageCc");
     $recipientsBcc = $this->_request->getValue("messageBcc");
     $text = $this->_request->getValue("messageText");
     $subject = $this->_request->getValue("messageSubject");
     // check that we've got either a 'to','cc' or 'bcc'
     if ($recipients == "" && $recipientsCc == "" && $recipientsBcc == "") {
         // force an error
         $this->_view = new MailCentreSendMessageView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("mailcentre_error_sending_message"));
         $this->_form->setFieldValidationStatus("messageRecipient", false);
         $this->setCommonData(true);
     }
     // pre-process some of the data
     $recipients = str_replace(" ", "", $recipients);
     $recipientsCc = str_replace(" ", "", $recipientsCc);
     $recipientsBcc = str_replace(" ", "", $recipientsBcc);
     // and get the list of recipients
     $listUnexpanded = explode(",", $recipients);
     $list = array();
     foreach ($listUnexpanded as $recipient) {
         $result = $this->_expandRecipients($recipient);
         $list = array_merge($list, $result);
     }
     $listCcUnexpanded = explode(",", $recipientsCc);
     $listCc = array();
     foreach ($listCcUnexpanded as $recipient) {
         $result = $this->_expandRecipients($recipient);
         $listCc = array_merge($listCc, $result);
     }
     $listBccUnexpanded = explode(",", $recipientsBcc);
     $listBcc = array();
     foreach ($listBccUnexpanded as $recipient) {
         $result = $this->_expandRecipients($recipient);
         $listBcc = array_merge($listBcc, $result);
     }
     // create a mail message that includes all the recipients
     $message = new EmailMessage();
     $val = new EmailValidator();
     $totalTo = 0;
     $totalCc = 0;
     $totalBcc = 0;
     foreach ($list as $to) {
         // add each one of the recipients
         if ($val->validate($to)) {
             $message->addTo($to);
             $totalTo++;
         }
     }
     foreach ($listCc as $cc) {
         // add each one of the recipients
         if ($val->validate($cc)) {
             $message->addCc($cc);
             $totalCc++;
         }
     }
     foreach ($listBcc as $bcc) {
         // add each one of the recipients
         if ($val->validate($bcc)) {
             $message->addBcc($bcc);
             $totalBcc++;
         }
     }
     // check that we are really sending the message to somebody
     if ($totalTo == 0 && $totalCc == 0 && $totalBcc == 0) {
         // force an error
         $this->_view = new MailCentreSendMessageView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("mailcentre_error_sending_message"));
         $this->_form->setFieldValidationStatus("messageRecipient", false);
         $this->setCommonData(true);
     }
     // and now set the subject and body...
     $message->setSubject($subject);
     $message->setBody($text);
     // set the encoding based on the current blog settings
     $locale =& $this->_blogInfo->getLocale();
     $message->setCharset($locale->getCharset());
     // and the "from" address
     $config =& Config::getConfig();
     $from = $config->getValue("post_notification_source_address");
     $message->setFrom($from);
     // now send the message
     $service = new EmailService();
     if (!$service->sendMessage($message)) {
         // if something went wrong, go back to the previous view
         $this->_view = new MailCentreSendMessageView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("mailcentre_error_sending_message"));
         // show the view and keep the data that was in the form
         $this->setCommonData(true);
     }
     $recipients = implode(",", $list);
     $recipientsCc = implode(",", $listCc);
     $recipientsBcc = implode(",", $listBcc);
     // if everything went ok, create our own MailMessage object and save it to the database
     $mailMessage = new MailMessage($subject, $text, $recipients, $recipientsCc, $recipientsBcc);
     $mailMessages = new MailMessages();
     $mailMessages->addMessage($mailMessage);
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:101,代码来源:mailcentresendmessage.class.php


注:本文中的EmailMessage::addBcc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。