Пример #1
0
 /**
  * This adds a recipient to the mail to send.
  *
  * @access  public
  * @param   string  $recipients    The recipients to add.
  * @param   string  $inform_type   Inform type(To, Bcc, Cc)
  * @return  bool    True
  */
 function AddRecipient($recipients = '', $inform_type = 'To')
 {
     $valid_recipients = array();
     $recipients = array_filter(array_map('Jaws_UTF8::trim', explode(',', $recipients)));
     foreach ($recipients as $key => $recipient) {
         if (false !== ($ltPos = Jaws_UTF8::strpos($recipient, '<'))) {
             $ename = Jaws_UTF8::encode_mimeheader(Jaws_UTF8::substr($recipient, 0, $ltPos));
             $email = Jaws_UTF8::substr($recipient, $ltPos + 1, -1);
             $recipients[$key] = $ename . "<{$email}>";
         } else {
             $ename = '';
             $email = $recipient;
             $recipients[$key] = $email;
         }
         // check blocked domains
         if (false !== strpos($this->blocked_domains, "\n" . substr(strrchr($email, '@'), 1))) {
             continue;
         }
         $valid_recipients[] = $recipients[$key];
     }
     if (empty($valid_recipients)) {
         if (!empty($this->site_name)) {
             $valid_recipients[] = Jaws_UTF8::encode_mimeheader($this->site_name) . ' <' . $this->site_email . '>';
         } else {
             $valid_recipients[] = $this->site_email;
         }
     }
     switch (strtolower($inform_type)) {
         case 'to':
             $this->headers['To'] = (array_key_exists('To', $this->headers) ? $this->headers['To'] . ',' : '') . implode(',', $valid_recipients);
             break;
         case 'cc':
             $this->headers['Cc'] = (array_key_exists('Cc', $this->headers) ? $this->headers['Cc'] . ',' : '') . implode(',', $valid_recipients);
             break;
     }
     $this->recipient = array_merge($this->recipient, $valid_recipients);
     return true;
 }