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


PHP Swift_RecipientList::add方法代码示例

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


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

示例1: getSwiftAddresses

 /**
  * Returns an instance of Swift_RecipientList, based on an address or an array of addresses.
  * 
  * @see getSwiftAddress()
  * 
  * @param $addresses
  * @return array of Swift_Address | Swift_RecipientList
  */
 protected static function getSwiftAddresses($addresses, $recipient_list = false, $type = 'to')
 {
     // Detect single address
     $address = self::getSwiftAddress($addresses);
     // Single address detected
     if ($address instanceof Swift_Address) {
         $result = array($address);
     } else {
         $result = array();
         foreach ($addresses as $address) {
             $result[] = self::getSwiftAddress($address);
         }
     }
     // transform into a recipient list if asked to
     if ($recipient_list) {
         $addresses = $result;
         $result = new Swift_RecipientList();
         $result->add($addresses, null, $type);
     }
     return $result;
 }
开发者ID:mediasadc,项目名称:alba,代码行数:29,代码来源:nahoMail.php

示例2: array

 /**
  * Mass mailer
  *
  * @param void
  * @return null
  */
 function mass_mailer()
 {
     if (!MASS_MAILER_ENABLED) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     $email_data = $this->request->post('email');
     $this->smarty->assign(array('email_data' => $email_data, 'exclude' => array($this->logged_user->getId())));
     if ($this->request->isSubmitted()) {
         $errors = new ValidationErrors();
         $subject = trim(array_var($email_data, 'subject'));
         $body = trim(array_var($email_data, 'body'));
         $recipient_ids = array_var($email_data, 'recipients');
         if (empty($subject)) {
             $errors->addError(lang('Subject is required'), 'subject');
         }
         // if
         if (empty($body)) {
             $errors->addError(lang('Body is required'), 'body');
         }
         // if
         $recipients = array();
         if (is_foreachable($recipient_ids)) {
             $recipients = Users::findByIds(array_unique($recipient_ids));
         }
         // if
         if (!is_foreachable($recipients)) {
             $errors->addError(lang('Please select recipients'), 'recipients');
         }
         // if
         if ($errors->hasErrors()) {
             $this->smarty->assign('errors', $errors);
             $this->render();
         }
         // if
         $mailer =& ApplicationMailer::mailer();
         $message = new Swift_Message($subject, $body, 'text/html', EMAIL_ENCODING, EMAIL_CHARSET);
         $recipients_list = new Swift_RecipientList();
         foreach ($recipients as $recipient) {
             $name = $recipient->getDisplayName();
             $email = $recipient->getEmail();
             if ($name == $email) {
                 $name = '';
             }
             // if
             $recipients_list->add($email, $name);
         }
         // foreach
         $name = $this->logged_user->getDisplayName();
         $email = $this->logged_user->getEmail();
         if ($name == $email) {
             $name = '';
         }
         // if
         if ($mailer->batchSend($message, $recipients_list, new Swift_Address($email, $name))) {
             flash_success('Email has been successfully sent');
         } else {
             flash_error('Failed to send email');
         }
         // if
         $this->redirectTo('admin_tools_mass_mailer');
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:70,代码来源:SystemToolsController.class.php


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