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


PHP Mail_RFC822::_splitAddresses方法代码示例

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


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

示例1: send

 /**
  * Send an email message.
  *
  * @access  public
  * @param   string  $to         Recipient email address
  * @param   string  $from       Sender email address
  * @param   string  $subject    Subject line for message
  * @param   string  $body       Message body
  * @param   string  $replyTo    Someone to reply to
  *
  * @return  mixed               PEAR error on error, boolean true otherwise
  */
 public function send($to, $from, $subject, $body, $replyTo = null)
 {
     global $logger;
     // Validate sender and recipient
     $validator = new Mail_RFC822();
     //Allow the to address to be split
     $validator->_splitAddresses($to);
     foreach ($validator->addresses as $tmpAddress) {
         if (!$validator->isValidInetAddress($tmpAddress['address'])) {
             return new PEAR_Error('Invalid Recipient Email Address ' . $tmpAddress);
         }
     }
     if (!$validator->isValidInetAddress($from)) {
         return new PEAR_Error('Invalid Sender Email Address');
     }
     $headers = array('To' => $to, 'Subject' => $subject, 'Date' => date('D, d M Y H:i:s O'), 'Content-Type' => 'text/plain; charset="UTF-8"');
     if (isset($this->settings['fromAddress'])) {
         $logger->log("Overriding From address, using " . $this->settings['fromAddress'], PEAR_LOG_INFO);
         $headers['From'] = $this->settings['fromAddress'];
         $headers['Reply-To'] = $from;
     } else {
         $headers['From'] = $from;
     }
     if ($replyTo != null) {
         $headers['Reply-To'] = $replyTo;
     }
     // Get mail object
     if ($this->settings['host'] != false) {
         $mailFactory = new Mail();
         $mail =& $mailFactory->factory('smtp', $this->settings);
         if (PEAR_Singleton::isError($mail)) {
             return $mail;
         }
         // Send message
         return $mail->send($to, $headers, $body);
     } else {
         //Mail to false just emits the information to screen
         $formattedMail = '';
         foreach ($headers as $key => $header) {
             $formattedMail .= $key . ': ' . $header . '<br />';
         }
         $formattedMail .= $body;
         $logger->log("Sending e-mail", PEAR_LOG_INFO);
         $logger->log("From = {$from}", PEAR_LOG_INFO);
         $logger->log("To = {$to}", PEAR_LOG_INFO);
         $logger->log($subject, PEAR_LOG_INFO);
         $logger->log($formattedMail, PEAR_LOG_INFO);
         return true;
     }
 }
开发者ID:victorfcm,项目名称:VuFind-Plus,代码行数:62,代码来源:Mailer.php


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