Beispiel #1
0
    public static function actionParse()
    {
        $tolist = 'apple@beta.com,
      Michael Ferranti <*****@*****.**>
      

    "Jeff Reifman" <*****@*****.**>, <*****@*****.**>,jeff <*****@*****.**>';
        //Yii::import('ext.Mail_RFC822');
        include 'Mail/RFC822.php';
        $parser = new Mail_RFC822();
        // replace the backslash quotes
        $tolist = str_replace('\\"', '"', $tolist);
        // split the elements by line and by comma
        $to_email_array = preg_split("(\r|\n|,)", $tolist, -1, PREG_SPLIT_NO_EMPTY);
        $num_emails = count($to_email_array);
        echo $num_emails;
        for ($count = 0; $count < $num_emails && $count <= 500; $count++) {
            $toAddress = trim($to_email_array[$count]);
            if ($toAddress != '') {
                $addresses = $parser->parseAddressList('my group:' . $toAddress, 'bushsucks.com', false, true);
                var_dump($addresses);
                lb();
            }
            //$toAddress=$addresses[0]->mailbox.'@'.$addresses[0]->host;
            //if ($this->utilObj->checkEmail($toAddress)) {
            // store it or send it or whatever you want to do
            //}
        }
    }
Beispiel #2
0
 /**
  * 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;
     }
 }
 function parseAddressList($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
 {
     if (!isset($this) || !isset($this->mailRFC822)) {
         $obj = new Mail_RFC822($address, $default_domain, $nest_groups, $validate, $limit);
         return $obj->parseAddressList();
     }
     if (isset($address)) {
         $this->address = $address;
     }
     if (isset($default_domain)) {
         $this->default_domain = $default_domain;
     }
     if (isset($nest_groups)) {
         $this->nestGroups = $nest_groups;
     }
     if (isset($validate)) {
         $this->validate = $validate;
     }
     if (isset($limit)) {
         $this->limit = $limit;
     }
     $this->structure = array();
     $this->addresses = array();
     $this->error = null;
     $this->index = null;
     $this->address = preg_replace('/\\r?\\n/', "\r\n", $this->address);
     $this->address = preg_replace('/\\r\\n(\\t| )+/', ' ', $this->address);
     while ($this->address = $this->_splitAddresses($this->address)) {
     }
     if ($this->address === false || isset($this->error)) {
         require_once 'PEAR.php';
         return PEAR::raiseError($this->error);
     }
     foreach ($this->addresses as $address) {
         $valid = $this->_validateAddress($address);
         if ($valid === false || isset($this->error)) {
             require_once 'PEAR.php';
             return PEAR::raiseError($this->error);
         }
         if (!$this->nestGroups) {
             $this->structure = array_merge($this->structure, $valid);
         } else {
             $this->structure[] = $valid;
         }
     }
     return $this->structure;
 }
Beispiel #4
0
 function updateOrCreateEmail($part = '', $opts, $cm = false)
 {
     // DB_DataObject::debugLevel(1);
     $template_name = preg_replace('/\\.[a-z]+$/i', '', basename($opts['file']));
     if (!file_exists($opts['file'])) {
         $this->jerr("file does not exist : " . $opts['file']);
     }
     if (!empty($opts['master']) && !file_exists($opts['master'])) {
         $this->jerr("master file does not exist : " . $opts['master']);
     }
     if (empty($cm)) {
         $cm = DB_dataObject::factory('core_email');
         $ret = $cm->get('name', $template_name);
         if ($ret && empty($opts['update'])) {
             $this->jerr("use --update 1 to update the template..");
         }
     }
     $mailtext = file_get_contents($opts['file']);
     if (!empty($opts['master'])) {
         $body = $mailtext;
         $mailtext = file_get_contents($opts['master']);
         $mailtext = str_replace('{outputBody():h}', $body, $mailtext);
     }
     require_once 'Mail/mimeDecode.php';
     require_once 'Mail/RFC822.php';
     $decoder = new Mail_mimeDecode($mailtext);
     $parts = $decoder->getSendArray();
     if (is_a($parts, 'PEAR_Error')) {
         echo $parts->toString() . "\n";
         exit;
     }
     $headers = $parts[1];
     $from = new Mail_RFC822();
     $from_str = $from->parseAddressList($headers['From']);
     $from_name = trim($from_str[0]->personal, '"');
     $from_email = $from_str[0]->mailbox . '@' . $from_str[0]->host;
     if ($cm->id) {
         $cc = clone $cm;
         $cm->setFrom(array('bodytext' => $parts[2], 'updated_dt' => date('Y-m-d H:i:s')));
         $cm->update($cc);
     } else {
         $cm->setFrom(array('from_name' => $from_name, 'from_email' => $from_email, 'subject' => $headers['Subject'], 'name' => $template_name, 'bodytext' => $parts[2], 'updated_dt' => date('Y-m-d H:i:s'), 'created_dt' => date('Y-m-d H:i:s')));
         $cm->insert();
     }
     return $cm;
 }
Beispiel #5
0
 /**
  * アドレスの羅列から名前とメールアドレスの連想配列を取得する
  *
  * @param $str メールヘッダに含まれるメールアドレスの羅列
  * @param メールアドレスの配列
  */
 static function get_mail_addr_array($str)
 {
     // メールアドレスリストとしてparse
     $mail_addr_obj_array = Mail_RFC822::parseAddressList($str);
     // メールアドレスを格納する配列
     $mail_addr_array = array();
     foreach ($mail_addr_obj_array as $mail_addr_obj) {
         // メールアドレス
         $mail_addr = $mail_addr_obj->mailbox . '@' . $mail_addr_obj->host;
         array_push($mail_addr_array, $mail_addr);
     }
     return $mail_addr_array;
 }
Beispiel #6
0
function valid_email($email)
{
    $emailObjects = Mail_RFC822::parseAddressList($email);
    if (PEAR::isError($emailObjects)) {
        return false;
    }
    $emailObject = $emailObjects[0];
    $email = $emailObject->mailbox . '@' . $emailObject->host;
    if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
        return false;
    } else {
        return true;
    }
}
Beispiel #7
0
 function register(&$data)
 {
     $session = Session::singletone();
     if (empty($data['user_login'])) {
         throw new Exception2("Nie mo¿na zarejestrowaæ konta", "Musisz podaæ login.");
     }
     if (empty($data['user_pass1']) || empty($data['user_pass2'])) {
         throw new Exception2("Nie mo¿na zarejestrowaæ konta", "Has³o nie mo¿e byæ puste.");
     }
     if (empty($data['user_email'])) {
         throw new Exception2("Nie mo¿na zarejestrowaæ konta", "Musisz podaæ email.");
     }
     $addr = Mail_RFC822::parseAddressList($data['user_email'], "");
     if (empty($addr)) {
         throw new Exception2("Nie mo¿na zarejestrowaæ konta", "Podany adres email jest nieprawid³owy.");
     }
     if ($data['user_pass1'] != $data['user_pass2']) {
         throw new Exception2("Nie mo¿na zarejestrowaæ konta", "Podane has³a ró¿ni± siê");
     }
     $user_login = trim($data['user_login']);
     $user_pass1 = $data['user_pass1'];
     $user_pass2 = $data['user_pass2'];
     $user_email = trim($data['user_email']);
     $this->_dbo = DB_DataObject::Factory('phph_users');
     if (PEAR::isError($this->_dbo)) {
         throw new Exception2(_INTERNAL_ERROR, $this->_dbo->getMessage());
     }
     $r = $this->_dbo->get('user_login', $user_login);
     if (PEAR::isError($r)) {
         throw new Exception2(_INTERNAL_ERROR, $r->getMessage());
     }
     if ($r != 0) {
         throw new Exception2("Nie mo¿na zarejestrowaæ konta", "Podany login jest ju¿ zajêty.");
     }
     $this->_dbo->user_login = $user_login;
     $this->_dbo->user_pass = md5($user_pass1);
     $this->_dbo->user_email = $user_email;
     $this->_dbo->user_registered = time();
     $this->_dbo->user_activation = md5(uniqid($user_login));
     $r = $this->_dbo->insert();
     if (PEAR::isError($r)) {
         throw new Exception2(_INTERNAL_ERROR, $r->getMessage());
     }
     return $r;
 }
Beispiel #8
0
function valid_email($email)
{
    $emailObjects = Mail_RFC822::parseAddressList($email);
    if (PEAR::isError($emailObjects)) {
        return false;
    }
    // Get the mailbox and host parts of the email object
    $mailbox = $emailObjects[0]->mailbox;
    $host = $emailObjects[0]->host;
    // Make sure the mailbox and host parts aren't too long
    if (strlen($mailbox) > 64) {
        return false;
    }
    if (strlen($host) > 255) {
        return false;
    }
    // Validate the mailbox
    $atom = '[[:alnum:]_!#$%&\'*+\\/=?^`{|}~-]+';
    $dotatom = '(\\.' . $atom . ')*';
    $address = '(^' . $atom . $dotatom . '$)';
    $char = '([^\\\\"])';
    $esc = '(\\\\[\\\\"])';
    $text = '(' . $char . '|' . $esc . ')+';
    $quoted = '(^"' . $text . '"$)';
    $localPart = '/' . $address . '|' . $quoted . '/';
    $localMatch = preg_match($localPart, $mailbox);
    if ($localMatch === false || $localMatch != 1) {
        return false;
    }
    // Validate the host
    $hostname = '([[:alnum:]]([-[:alnum:]]{0,62}[[:alnum:]])?)';
    $hostnames = '(' . $hostname . '(\\.' . $hostname . ')*)';
    $top = '\\.[[:alnum:]]{2,6}';
    $domainPart = '/^' . $hostnames . $top . '$/';
    $domainMatch = preg_match($domainPart, $host);
    if ($domainMatch === false || $domainMatch != 1) {
        return false;
    }
    return true;
}
Beispiel #9
0
 /**
  * Send an email message.
  *
  * @param string $to      Recipient email address
  * @param string $from    Sender email address
  * @param string $subject Subject line for message
  * @param string $body    Message body
  *
  * @return mixed          PEAR error on error, boolean true otherwise
  * @access public
  */
 public function send($to, $from, $subject, $body)
 {
     // Validate sender and recipient
     if (!Mail_RFC822::isValidInetAddress($to)) {
         return new PEAR_Error('Invalid Recipient Email Address');
     }
     if (!Mail_RFC822::isValidInetAddress($from)) {
         return new PEAR_Error('Invalid Sender Email Address');
     }
     // Change error handling behavior to avoid termination during mail
     // process....
     PEAR::setErrorHandling(PEAR_ERROR_RETURN);
     // Get mail object
     $mail =& Mail::factory('smtp', $this->settings);
     if (PEAR::isError($mail)) {
         return $mail;
     }
     // Send message
     $headers = array('From' => $from, 'To' => $to, 'Subject' => $subject, 'Date' => date('D, d M Y H:i:s O'), 'Content-Type' => 'text/plain; charset="UTF-8"');
     $result = $mail->send($to, $headers, $body);
     return $result;
 }
Beispiel #10
0
 /**
  * Starts the whole process. The address must either be set here
  * or when creating the object. One or the other.
  *
  * @access public
  * @param string  $address         The address(es) to validate.
  * @param string  $default_domain  Default domain/host etc.
  * @param boolean $nest_groups     Whether to return the structure with groups nested for easier viewing.
  * @param boolean $validate        Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
  * 
  * @return array A structured array of addresses.
  */
 function parseAddressList($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
 {
     if (!isset($this->mailRFC822)) {
         $obj = new Mail_RFC822($address, $default_domain, $nest_groups, $validate, $limit);
         return $obj->parseAddressList();
     }
     if (isset($address)) {
         $this->address = $address;
     }
     if (isset($default_domain)) {
         $this->default_domain = $default_domain;
     }
     if (isset($nest_groups)) {
         $this->nestGroups = $nest_groups;
     }
     if (isset($validate)) {
         $this->validate = $validate;
     }
     if (isset($limit)) {
         $this->limit = $limit;
     }
     $this->structure = array();
     $this->addresses = array();
     $this->error = null;
     $this->index = null;
     while ($this->address = $this->_splitAddresses($this->address)) {
         continue;
     }
     if ($this->address === false || isset($this->error)) {
         return $this->raiseError($this->error);
     }
     // Reset timer since large amounts of addresses can take a long time to
     // get here
     set_time_limit(30);
     // Loop through all the addresses
     for ($i = 0; $i < count($this->addresses); $i++) {
         if (($return = $this->_validateAddress($this->addresses[$i])) === false || isset($this->error)) {
             return $this->raiseError($this->error);
         }
         if (!$this->nestGroups) {
             $this->structure = array_merge($this->structure, $return);
         } else {
             $this->structure[] = $return;
         }
     }
     return $this->structure;
 }
Beispiel #11
0
 /**
  * Take a set of recipients and parse them, returning an array of
  * bare addresses (forward paths) that can be passed to sendmail
  * or an smtp server with the rcpt to: command.
  *
  * @param mixed Either a comma-seperated list of recipients
  *              (RFC822 compliant), or an array of recipients,
  *              each RFC822 valid.
  *
  * @return array An array of forward paths (bare addresses).
  * @access private
  */
 function parseRecipients($recipients)
 {
     include_once 'Mail/RFC822.php';
     // if we're passed an array, assume addresses are valid and
     // implode them before parsing.
     if (is_array($recipients)) {
         $recipients = implode(', ', $recipients);
     }
     // Parse recipients, leaving out all personal info. This is
     // for smtp recipients, etc. All relevant personal information
     // should already be in the headers.
     $addresses = Mail_RFC822::parseAddressList($recipients, 'localhost', false);
     $recipients = array();
     if (is_array($addresses)) {
         foreach ($addresses as $ob) {
             $recipients[] = $ob->mailbox . '@' . $ob->host;
         }
     }
     return $recipients;
 }
Beispiel #12
0
 /**
  * Sends the mail.
  *
  * @param  array  $recipients Array of receipients to send the mail to
  * @param  string $type       How to send the mail ('mail' or 'sendmail' or 'smtp')
  * @return mixed
  */
 public function send($recipients, $type = 'mail')
 {
     if (!defined('CRLF')) {
         $this->setCRLF(($type == 'mail' or $type == 'sendmail') ? "\n" : "\r\n");
     }
     $this->build();
     switch ($type) {
         case 'mail':
             $subject = '';
             if (!empty($this->headers['Subject'])) {
                 $subject = $this->encodeHeader($this->headers['Subject'], $this->build_params['head_charset']);
                 unset($this->headers['Subject']);
             }
             // Get flat representation of headers
             foreach ($this->headers as $name => $value) {
                 $headers[] = $name . ': ' . $this->encodeHeader($value, $this->build_params['head_charset']);
             }
             $to = $this->encodeHeader(implode(', ', $recipients), $this->build_params['head_charset']);
             if (!empty($this->return_path)) {
                 $result = mail($to, $subject, $this->output, implode(CRLF, $headers), '-f' . $this->return_path);
             } else {
                 $result = mail($to, $subject, $this->output, implode(CRLF, $headers));
             }
             // Reset the subject in case mail is resent
             if ($subject !== '') {
                 $this->headers['Subject'] = $subject;
             }
             // Return
             return $result;
             break;
         case 'sendmail':
             // Get flat representation of headers
             foreach ($this->headers as $name => $value) {
                 $headers[] = $name . ': ' . $this->encodeHeader($value, $this->build_params['head_charset']);
             }
             // Encode To:
             $headers[] = 'To: ' . $this->encodeHeader(implode(', ', $recipients), $this->build_params['head_charset']);
             // Get return path arg for sendmail command if necessary
             $returnPath = '';
             if (!empty($this->return_path)) {
                 $returnPath = '-f' . $this->return_path;
             }
             $pipe = popen($this->sendmail_path . " " . $returnPath, 'w');
             $bytes = fputs($pipe, implode(CRLF, $headers) . CRLF . CRLF . $this->output);
             $r = pclose($pipe);
             return $r;
             break;
         case 'smtp':
             require_once dirname(__FILE__) . '/smtp.php';
             require_once dirname(__FILE__) . '/RFC822.php';
             $smtp =& smtp::connect($this->smtp_params);
             // Parse recipients argument for internet addresses
             foreach ($recipients as $recipient) {
                 $addresses = Mail_RFC822::parseAddressList($recipient, $this->smtp_params['helo'], null, false);
                 foreach ($addresses as $address) {
                     $smtp_recipients[] = sprintf('%s@%s', $address->mailbox, $address->host);
                 }
             }
             unset($addresses);
             // These are reused
             unset($address);
             // These are reused
             // Get flat representation of headers, parsing
             // Cc and Bcc as we go
             foreach ($this->headers as $name => $value) {
                 if ($name == 'Cc' or $name == 'Bcc') {
                     $addresses = Mail_RFC822::parseAddressList($value, $this->smtp_params['helo'], null, false);
                     foreach ($addresses as $address) {
                         $smtp_recipients[] = sprintf('%s@%s', $address->mailbox, $address->host);
                     }
                 }
                 if ($name == 'Bcc') {
                     continue;
                 }
                 $headers[] = $name . ': ' . $this->encodeHeader($value, $this->build_params['head_charset']);
             }
             // Add To header based on $recipients argument
             $headers[] = 'To: ' . $this->encodeHeader(implode(', ', $recipients), $this->build_params['head_charset']);
             // Add headers to send_params
             $send_params['headers'] = $headers;
             $send_params['recipients'] = array_values(array_unique($smtp_recipients));
             $send_params['body'] = $this->output;
             // Setup return path
             if (isset($this->return_path)) {
                 $send_params['from'] = $this->return_path;
             } elseif (!empty($this->headers['From'])) {
                 $from = Mail_RFC822::parseAddressList($this->headers['From']);
                 $send_params['from'] = sprintf('%s@%s', $from[0]->mailbox, $from[0]->host);
             } else {
                 $send_params['from'] = 'postmaster@' . $this->smtp_params['helo'];
             }
             // Send it
             if (!$smtp->send($send_params)) {
                 $this->errors = $smtp->getErrors();
                 return false;
             }
             return true;
             break;
     }
 }
Beispiel #13
0
 /**
  * Starts the whole process. The address must either be set here
  * or when creating the object. One or the other.
  *
  * @access public
  * @param string  $address         The address(es) to validate.
  * @param string  $default_domain  Default domain/host etc.
  * @param boolean $nest_groups     Whether to return the structure with groups nested for easier viewing.
  * @param boolean $validate        Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
  *
  * @return array A structured array of addresses.
  */
 function parseAddressList($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
 {
     if (!isset($this) || !isset($this->mailRFC822)) {
         $obj = new Mail_RFC822($address, $default_domain, $nest_groups, $validate, $limit);
         return $obj->parseAddressList();
     }
     if (isset($address)) {
         $this->address = $address;
     }
     if (isset($default_domain)) {
         $this->default_domain = $default_domain;
     }
     if (isset($nest_groups)) {
         $this->nestGroups = $nest_groups;
     }
     if (isset($validate)) {
         $this->validate = $validate;
     }
     if (isset($limit)) {
         $this->limit = $limit;
     }
     $this->structure = array();
     $this->addresses = array();
     $this->error = null;
     $this->index = null;
     // Unfold any long lines in $this->address.
     $this->address = preg_replace('/\\r?\\n/', "\r\n", $this->address);
     $this->address = preg_replace('/\\r\\n(\\t| )+/', ' ', $this->address);
     while ($this->address = $this->_splitAddresses($this->address)) {
     }
     if ($this->address === false || isset($this->error)) {
         //require_once 'PEAR.php';
         return $this->raiseError($this->error);
     }
     // Validate each address individually.  If we encounter an invalid
     // address, stop iterating and return an error immediately.
     foreach ($this->addresses as $address) {
         $valid = $this->_validateAddress($address);
         if ($valid === false || isset($this->error)) {
             //require_once 'PEAR.php';
             return $this->raiseError($this->error);
         }
         if (!$this->nestGroups) {
             $this->structure = array_merge($this->structure, $valid);
         } else {
             $this->structure[] = $valid;
         }
     }
     return $this->structure;
 }
Beispiel #14
0
 /**
  * Get Patron Profile
  *
  * This is responsible for retrieving the profile for a specific patron.
  *
  * @param array $patron The patron array
  *
  * @return mixed        Array of the patron's profile data on success,
  * PEAR_Error otherwise.
  * @access public
  */
 public function getMyProfile($patron)
 {
     $sql = "SELECT PATRON.LAST_NAME, PATRON.FIRST_NAME, " . "PATRON.HISTORICAL_CHARGES, PATRON_ADDRESS.ADDRESS_LINE1, " . "PATRON_ADDRESS.ADDRESS_LINE2, PATRON_ADDRESS.ZIP_POSTAL, " . "PATRON_ADDRESS.CITY, PATRON_ADDRESS.COUNTRY, " . "PATRON_PHONE.PHONE_NUMBER, PATRON_GROUP.PATRON_GROUP_NAME " . "FROM {$this->dbName}.PATRON, {$this->dbName}.PATRON_ADDRESS, " . "{$this->dbName}.PATRON_PHONE, {$this->dbName}.PATRON_BARCODE, " . "{$this->dbName}.PATRON_GROUP " . "WHERE PATRON.PATRON_ID = PATRON_ADDRESS.PATRON_ID (+) " . "AND PATRON_ADDRESS.ADDRESS_ID = PATRON_PHONE.ADDRESS_ID (+) " . "AND PATRON.PATRON_ID = PATRON_BARCODE.PATRON_ID (+) " . "AND PATRON_BARCODE.PATRON_GROUP_ID = " . "PATRON_GROUP.PATRON_GROUP_ID (+) " . "AND PATRON.PATRON_ID = :id";
     try {
         $sqlStmt = $this->db->prepare($sql);
         $this->debugLogSQL(__FUNCTION__, $sql, array(':id' => $patron['id']));
         $sqlStmt->execute(array(':id' => $patron['id']));
         $patron = array();
         while ($row = $sqlStmt->fetch(PDO::FETCH_ASSOC)) {
             if (!empty($row['FIRST_NAME'])) {
                 $patron['firstname'] = utf8_encode($row['FIRST_NAME']);
             }
             if (!empty($row['LAST_NAME'])) {
                 $patron['lastname'] = utf8_encode($row['LAST_NAME']);
             }
             if (!empty($row['PHONE_NUMBER'])) {
                 $patron['phone'] = utf8_encode($row['PHONE_NUMBER']);
             }
             if (!empty($row['PATRON_GROUP_NAME'])) {
                 $patron['group'] = utf8_encode($row['PATRON_GROUP_NAME']);
             }
             include_once 'Mail/RFC822.php';
             $addr1 = utf8_encode($row['ADDRESS_LINE1']);
             if (Mail_RFC822::isValidInetAddress($addr1)) {
                 $patron['email'] = $addr1;
             } else {
                 if (!isset($patron['address1'])) {
                     if (!empty($addr1)) {
                         $patron['address1'] = $addr1;
                     }
                     if (!empty($row['ADDRESS_LINE2'])) {
                         $patron['address2'] = utf8_encode($row['ADDRESS_LINE2']);
                     }
                     $patron['zip'] = !empty($row['ZIP_POSTAL']) ? utf8_encode($row['ZIP_POSTAL']) : '';
                     if (!empty($row['CITY'])) {
                         if ($patron['zip']) {
                             $patron['zip'] .= ' ';
                         }
                         $patron['zip'] .= utf8_encode($row['CITY']);
                     }
                     if (!empty($row['COUNTRY'])) {
                         if ($patron['zip']) {
                             $patron['zip'] .= ', ';
                         }
                         $patron['zip'] .= utf8_encode($row['COUNTRY']);
                     }
                 }
             }
         }
         return empty($patron) ? null : $patron;
     } catch (PDOException $e) {
         return new PEAR_Error($e->getMessage());
     }
 }
Beispiel #15
0
 function SendMail($rfc822, $forward = false, $reply = false, $parent = false)
 {
     debugLog("IMAP-SendMail: " . $rfc822 . "for: {$forward}   reply: {$reply}   parent: {$parent}");
     $mobj = new Mail_mimeDecode($rfc822);
     $message = $mobj->decode(array('decode_headers' => false, 'decode_bodies' => true, 'include_bodies' => true, 'input' => $rfc822, 'crlf' => "\n", 'charset' => 'utf-8'));
     $toaddr = $ccaddr = $bccaddr = "";
     if (isset($message->headers["to"])) {
         $toaddr = $this->parseAddr(Mail_RFC822::parseAddressList($message->headers["to"]));
     }
     if (isset($message->headers["cc"])) {
         $ccaddr = $this->parseAddr(Mail_RFC822::parseAddressList($message->headers["cc"]));
     }
     if (isset($message->headers["bcc"])) {
         $bccaddr = $this->parseAddr(Mail_RFC822::parseAddressList($message->headers["bcc"]));
     }
     // save some headers when forwarding mails (content type & transfer-encoding)
     $headers = "";
     $forward_h_ct = "";
     $forward_h_cte = "";
     $use_orgbody = false;
     // clean up the transmitted headers
     // remove default headers because we are using imap_mail
     $changedfrom = false;
     $returnPathSet = false;
     $body_base64 = false;
     $org_charset = "";
     foreach ($message->headers as $k => $v) {
         if ($k == "subject" || $k == "to" || $k == "cc" || $k == "bcc") {
             continue;
         }
         if ($k == "content-type") {
             // save the original content-type header for the body part when forwarding
             if ($forward) {
                 $forward_h_ct = $v;
                 continue;
             }
             // set charset always to utf-8
             $org_charset = $v;
             $v = preg_replace("/charset=([A-Za-z0-9-\"']+)/", "charset=\"utf-8\"", $v);
         }
         if ($k == "content-transfer-encoding") {
             // if the content was base64 encoded, encode the body again when sending
             if (trim($v) == "base64") {
                 $body_base64 = true;
             }
             // save the original encoding header for the body part when forwarding
             if ($forward) {
                 $forward_h_cte = $v;
                 continue;
             }
         }
         // if the message is a multipart message, then we should use the sent body
         if (!$forward && $k == "content-type" && preg_match("/multipart/i", $v)) {
             $use_orgbody = true;
         }
         // check if "from"-header is set
         if ($k == "from" && !trim($v) && IMAP_DEFAULTFROM) {
             $changedfrom = true;
             if (IMAP_DEFAULTFROM == 'username') {
                 $v = $this->_username;
             } else {
                 if (IMAP_DEFAULTFROM == 'domain') {
                     $v = $this->_domain;
                 } else {
                     $v = $this->_username . IMAP_DEFAULTFROM;
                 }
             }
         }
         // check if "Return-Path"-header is set
         if ($k == "return-path") {
             $returnPathSet = true;
             if (!trim($v) && IMAP_DEFAULTFROM) {
                 if (IMAP_DEFAULTFROM == 'username') {
                     $v = $this->_username;
                 } else {
                     if (IMAP_DEFAULTFROM == 'domain') {
                         $v = $this->_domain;
                     } else {
                         $v = $this->_username . IMAP_DEFAULTFROM;
                     }
                 }
             }
         }
         // all other headers stay
         if ($headers) {
             $headers .= "\n";
         }
         $headers .= ucfirst($k) . ": " . $v;
     }
     // set "From" header if not set on the device
     if (IMAP_DEFAULTFROM && !$changedfrom) {
         if (IMAP_DEFAULTFROM == 'username') {
             $v = $this->_username;
         } else {
             if (IMAP_DEFAULTFROM == 'domain') {
                 $v = $this->_domain;
             } else {
                 $v = $this->_username . IMAP_DEFAULTFROM;
             }
         }
         if ($headers) {
             $headers .= "\n";
         }
         $headers .= 'From: ' . $v;
     }
     // set "Return-Path" header if not set on the device
     if (IMAP_DEFAULTFROM && !$returnPathSet) {
         if (IMAP_DEFAULTFROM == 'username') {
             $v = $this->_username;
         } else {
             if (IMAP_DEFAULTFROM == 'domain') {
                 $v = $this->_domain;
             } else {
                 $v = $this->_username . IMAP_DEFAULTFROM;
             }
         }
         if ($headers) {
             $headers .= "\n";
         }
         $headers .= 'Return-Path: ' . $v;
     }
     // if this is a multipart message with a boundary, we must use the original body
     if ($use_orgbody) {
         list(, $body) = $mobj->_splitBodyHeader($rfc822);
     } else {
         $body = $this->getBody($message);
     }
     // reply
     if (isset($reply) && isset($parent) && $reply && $parent) {
         $this->imap_reopenFolder($parent);
         // receive entire mail (header + body) to decode body correctly
         $origmail = @imap_fetchheader($this->_mbox, $reply, FT_PREFETCHTEXT | FT_UID) . @imap_body($this->_mbox, $reply, FT_PEEK | FT_UID);
         $mobj2 = new Mail_mimeDecode($origmail);
         // receive only body
         $body .= $this->getBody($mobj2->decode(array('decode_headers' => false, 'decode_bodies' => true, 'include_bodies' => true, 'input' => $origmail, 'crlf' => "\n", 'charset' => 'utf-8')));
         // unset mimedecoder & origmail - free memory
         unset($mobj2);
         unset($origmail);
     }
     // encode the body to base64 if it was sent originally in base64 by the pda
     // the encoded body is included in the forward
     if ($body_base64) {
         $body = base64_encode($body);
     }
     // forward
     if (isset($forward) && isset($parent) && $forward && $parent) {
         $this->imap_reopenFolder($parent);
         // receive entire mail (header + body)
         $origmail = @imap_fetchheader($this->_mbox, $forward, FT_PREFETCHTEXT | FT_UID) . @imap_body($this->_mbox, $forward, FT_PEEK | FT_UID);
         // build a new mime message, forward entire old mail as file
         list($aheader, $body) = $this->mail_attach("forwarded_message.eml", strlen($origmail), $origmail, $body, $forward_h_ct, $forward_h_cte);
         // unset origmail - free memory
         unset($origmail);
         // add boundary headers
         $headers .= "\n" . $aheader;
     }
     //advanced debugging
     //debugLog("IMAP-SendMail: parsed message: ". print_r($message,1));
     //debugLog("IMAP-SendMail: headers: $headers");
     //debugLog("IMAP-SendMail: subject: {$message->headers["subject"]}");
     //debugLog("IMAP-SendMail: body: $body");
     $send = @imap_mail($toaddr, $message->headers["subject"], $body, $headers, $ccaddr, $bccaddr);
     // email sent?
     if (!$send) {
         debugLog("The email could not be sent. Last-IMAP-error: " . imap_last_error());
     }
     // add message to the sent folder
     // build complete headers
     $cheaders = "To: " . $toaddr . "\n";
     $cheaders .= "Subject: " . $message->headers["subject"] . "\n";
     $cheaders .= "Cc: " . $ccaddr . "\n";
     $cheaders .= $headers;
     $asf = false;
     if ($this->_sentID) {
         $asf = $this->addSentMessage($this->_sentID, $cheaders, $body);
     } else {
         if (IMAP_SENTFOLDER) {
             $asf = $this->addSentMessage(IMAP_SENTFOLDER, $cheaders, $body);
             debugLog("IMAP-SendMail: Outgoing mail saved in configured 'Sent' folder '" . IMAP_SENTFOLDER . "': " . ($asf ? "success" : "failed"));
         } else {
             debugLog("IMAP-SendMail: No Sent mailbox set");
             if ($this->addSentMessage("INBOX.Sent", $cheaders, $body)) {
                 debugLog("IMAP-SendMail: Outgoing mail saved in 'INBOX.Sent'");
                 $asf = true;
             } else {
                 if ($this->addSentMessage("Sent", $cheaders, $body)) {
                     debugLog("IMAP-SendMail: Outgoing mail saved in 'Sent'");
                     $asf = true;
                 } else {
                     if ($this->addSentMessage("Sent Items", $cheaders, $body)) {
                         debugLog("IMAP-SendMail: Outgoing mail saved in 'Sent Items'");
                         $asf = true;
                     }
                 }
             }
         }
     }
     // unset mimedecoder - free memory
     unset($mobj);
     return $send && $asf;
 }
Beispiel #16
0
if (isset($Action) && $Action == "Update") {
    /* To do: Add JavaScript to verify passwords _before_ sending the form here */
    if ($password0 != $password1) {
        print_header(0, 0, 0, "");
        print get_vocab("passwords_not_eq") . "<br>\n";
        print "<form method=post action=\"" . basename($PHP_SELF) . "\">\n";
        print "  <input type=submit value=\" " . get_vocab("ok") . " \" /> <br />\n";
        print "</form>\n</body>\n</html>\n";
        exit;
    }
    //
    // Verify email adresses
    include_once 'Mail/RFC822.php';
    !isset($Field[3]) ? $Field[3] = '' : '';
    $emails = explode(',', $Field[3]);
    $valid_email = new Mail_RFC822();
    foreach ($emails as $email) {
        // if no email address is entered, this is OK, even if isValidInetAddress
        // does not return TRUE
        if (!$valid_email->isValidInetAddress($email, $strict = FALSE) && '' != $Field[3]) {
            // Now display this form again with an error message
            Header("Location: edit_users.php?Action=Edit&Id={$Id}&invalid_email=1");
            exit;
        }
    }
    //
    if ($Id >= 0) {
        $operation = "replace into {$tbl_users} values (";
    } else {
        $operation = "insert into {$tbl_users} values (";
        $Id = sql_query1("select max(id) from {$tbl_users};") + 1;
Beispiel #17
0
     print "  <legend></legend>\n";
     print "    <p class=\"error\">" . get_vocab("passwords_not_eq") . "</p>\n";
     print "    <input type=\"submit\" value=\" " . get_vocab("ok") . " \">\n";
     print "  </fieldset>\n";
     print "</form>\n</body>\n</html>\n";
     exit;
 }
 //
 // Verify email adresses
 include_once 'Mail/RFC822.php';
 $email_var = get_form_var('Field_email', 'string');
 if (!isset($email_var)) {
     $email_var = '';
 }
 $emails = explode(',', $email_var);
 $valid_email = new Mail_RFC822();
 foreach ($emails as $email) {
     // if no email address is entered, this is OK, even if isValidInetAddress
     // does not return TRUE
     if (!$valid_email->isValidInetAddress($email, $strict = FALSE) && '' != $email_var) {
         // Now display this form again with an error message
         Header("Location: edit_users.php?Action=Edit&Id={$Id}&invalid_email=1");
         exit;
     }
 }
 //
 if ($Id >= 0) {
     $operation = "replace into {$tbl_users} values (";
 } else {
     $operation = "insert into {$tbl_users} values (";
     $Id = sql_query1("select max(id) from {$tbl_users};") + 1;
Beispiel #18
0
/**
* Checks to see if email address is valid.
*
* This function checks to see if an email address is in the correct from.
*
* @param    string    $email   Email address to verify
* @return   boolean            True if valid otherwise false
*
*/
function COM_isEmail($email)
{
    require_once 'Mail/RFC822.php';
    $rfc822 = new Mail_RFC822();
    return $rfc822->isValidInetAddress($email) ? true : false;
}
}
//exit();
//get all the destined addresses from to,cc,bcc into the array $var_toaddress
//do check for duplicates and insert all valid addresses to $var_toaddress array
$var_toaddress = array();
for ($j = 0; $j < 3; $j++) {
    $structure = "";
    switch ($j) {
        case 0:
            $structure = Mail_RFC822::parseAddressList($mimedecoder->_mailheader->_headerto, 'example.com', true);
            break;
        case 1:
            $structure = Mail_RFC822::parseAddressList($mimedecoder->_mailheader->_headercc, 'example.com', true);
            break;
        case 2:
            $structure = Mail_RFC822::parseAddressList($mimedecoder->_mailheader->_headerbcc, 'example.com', true);
            break;
    }
    $cnt = count($structure);
    for ($i = 0; $i < $cnt; $i++) {
        $var_temp = $structure[$i]->mailbox . "@" . strtolower($structure[$i]->host);
        if ($structure[$i]->mailbox != "" && !isset($var_toaddress[$var_temp])) {
            $var_toaddress[$var_temp] = $structure[$i]->mailbox;
        }
    }
}
//print_r($var_toaddress);
/*
 *Case-sensitivity for isset - it is case sensitive
 *so same email addresses with different case may create two tickets
 *se we convert all domain names to lower case here
Beispiel #20
0
 function SendMail($rfc822, $forward = false, $reply = false, $parent = false)
 {
     if (WBXML_DEBUG == true) {
         debugLog("SendMail: forward: {$forward}   reply: {$reply}   parent: {$parent}\n" . $rfc822);
     }
     $mimeParams = array('decode_headers' => true, 'decode_bodies' => true, 'include_bodies' => true, 'charset' => 'utf-8');
     $mimeObject = new Mail_mimeDecode($rfc822);
     $message = $mimeObject->decode($mimeParams);
     // Open the outbox and create the message there
     $storeprops = mapi_getprops($this->_defaultstore, array(PR_IPM_OUTBOX_ENTRYID, PR_IPM_SENTMAIL_ENTRYID));
     if (!isset($storeprops[PR_IPM_OUTBOX_ENTRYID])) {
         debugLog("Outbox not found to create message");
         return false;
     }
     $outbox = mapi_msgstore_openentry($this->_defaultstore, $storeprops[PR_IPM_OUTBOX_ENTRYID]);
     if (!$outbox) {
         debugLog("Unable to open outbox");
         return false;
     }
     $mapimessage = mapi_folder_createmessage($outbox);
     mapi_setprops($mapimessage, array(PR_SUBJECT => u2wi(isset($message->headers["subject"]) ? $message->headers["subject"] : ""), PR_SENTMAIL_ENTRYID => $storeprops[PR_IPM_SENTMAIL_ENTRYID], PR_MESSAGE_CLASS => "IPM.Note", PR_MESSAGE_DELIVERY_TIME => time()));
     if (isset($message->headers["x-priority"])) {
         switch ($message->headers["x-priority"]) {
             case 1:
             case 2:
                 $priority = PRIO_URGENT;
                 $importance = IMPORTANCE_HIGH;
                 break;
             case 4:
             case 5:
                 $priority = PRIO_NONURGENT;
                 $importance = IMPORTANCE_LOW;
                 break;
             case 3:
             default:
                 $priority = PRIO_NORMAL;
                 $importance = IMPORTANCE_NORMAL;
                 break;
         }
         mapi_setprops($mapimessage, array(PR_IMPORTANCE => $importance, PR_PRIORITY => $priority));
     }
     $addresses = array();
     $toaddr = $ccaddr = $bccaddr = array();
     $Mail_RFC822 = new Mail_RFC822();
     if (isset($message->headers["to"])) {
         $toaddr = $Mail_RFC822->parseAddressList($message->headers["to"]);
     }
     if (isset($message->headers["cc"])) {
         $ccaddr = $Mail_RFC822->parseAddressList($message->headers["cc"]);
     }
     if (isset($message->headers["bcc"])) {
         $bccaddr = $Mail_RFC822->parseAddressList($message->headers["bcc"]);
     }
     // Add recipients
     $recips = array();
     if (isset($toaddr)) {
         foreach (array(MAPI_TO => $toaddr, MAPI_CC => $ccaddr, MAPI_BCC => $bccaddr) as $type => $addrlist) {
             foreach ($addrlist as $addr) {
                 $mapirecip[PR_ADDRTYPE] = "SMTP";
                 $mapirecip[PR_EMAIL_ADDRESS] = $addr->mailbox . "@" . $addr->host;
                 if (isset($addr->personal) && strlen($addr->personal) > 0) {
                     $mapirecip[PR_DISPLAY_NAME] = u2wi($addr->personal);
                 } else {
                     $mapirecip[PR_DISPLAY_NAME] = $mapirecip[PR_EMAIL_ADDRESS];
                 }
                 $mapirecip[PR_RECIPIENT_TYPE] = $type;
                 $mapirecip[PR_ENTRYID] = mapi_createoneoff($mapirecip[PR_DISPLAY_NAME], $mapirecip[PR_ADDRTYPE], $mapirecip[PR_EMAIL_ADDRESS]);
                 array_push($recips, $mapirecip);
             }
         }
     }
     mapi_message_modifyrecipients($mapimessage, 0, $recips);
     // Loop through message subparts.
     $body = "";
     $body_html = "";
     if ($message->ctype_primary == "multipart" && ($message->ctype_secondary == "mixed" || $message->ctype_secondary == "alternative")) {
         $mparts = $message->parts;
         for ($i = 0; $i < count($mparts); $i++) {
             $part = $mparts[$i];
             // palm pre & iPhone send forwarded messages in another subpart which are also parsed
             if ($part->ctype_primary == "multipart" && ($part->ctype_secondary == "mixed" || $part->ctype_secondary == "alternative" || $part->ctype_secondary == "related")) {
                 foreach ($part->parts as $spart) {
                     $mparts[] = $spart;
                 }
                 continue;
             }
             // standard body
             if ($part->ctype_primary == "text" && $part->ctype_secondary == "plain" && isset($part->body) && (!isset($part->disposition) || $part->disposition != "attachment")) {
                 $body .= u2wi($part->body);
                 // assume only one text body
             } elseif ($part->ctype_primary == "text" && $part->ctype_secondary == "html") {
                 $body_html .= u2wi($part->body);
             } elseif ($part->ctype_primary == "ms-tnef" || $part->ctype_secondary == "ms-tnef") {
                 $zptnef = new ZPush_tnef($this->_defaultstore);
                 $mapiprops = array();
                 $zptnef->extractProps($part->body, $mapiprops);
                 if (is_array($mapiprops) && !empty($mapiprops)) {
                     //check if it is a recurring item
                     $tnefrecurr = GetPropIDFromString($this->_defaultstore, "PT_BOOLEAN:{6ED8DA90-450B-101B-98DA-00AA003F1305}:0x5");
                     if (isset($mapiprops[$tnefrecurr])) {
                         $this->_handleRecurringItem($mapimessage, $mapiprops);
                     }
                     mapi_setprops($mapimessage, $mapiprops);
                 } else {
                     debugLog("TNEF: Mapi props array was empty");
                 }
             } elseif ($part->ctype_primary == "text" && $part->ctype_secondary == "calendar") {
                 $zpical = new ZPush_ical($this->_defaultstore);
                 $mapiprops = array();
                 $zpical->extractProps($part->body, $mapiprops);
                 // iPhone sends a second ICS which we ignore if we can
                 if (!isset($mapiprops[PR_MESSAGE_CLASS]) && strlen(trim($body)) == 0) {
                     debugLog("Secondary iPhone response is being ignored!! Mail dropped!");
                     return true;
                 }
                 if (!checkMapiExtVersion("6.30") && is_array($mapiprops) && !empty($mapiprops)) {
                     mapi_setprops($mapimessage, $mapiprops);
                 } else {
                     // store ics as attachment
                     //see icalTimezoneFix function in compat.php for more information
                     $part->body = icalTimezoneFix($part->body);
                     $this->_storeAttachment($mapimessage, $part);
                     debugLog("Sending ICS file as attachment");
                 }
             } else {
                 $this->_storeAttachment($mapimessage, $part);
             }
         }
     } else {
         if ($message->ctype_primary == "text" && $message->ctype_secondary == "html") {
             $body_html .= u2wi($message->body);
         } else {
             $body = u2wi($message->body);
         }
     }
     // some devices only transmit a html body
     if (strlen($body) == 0 && strlen($body_html) > 0) {
         debugLog("only html body sent, transformed into plain text");
         $body = strip_tags($body_html);
     }
     if ($forward) {
         $orig = $forward;
     }
     if ($reply) {
         $orig = $reply;
     }
     if (isset($orig) && $orig) {
         // Append the original text body for reply/forward
         $entryid = mapi_msgstore_entryidfromsourcekey($this->_defaultstore, hex2bin($parent), hex2bin($orig));
         $fwmessage = mapi_msgstore_openentry($this->_defaultstore, $entryid);
         if ($fwmessage) {
             //update icon when forwarding or replying message
             if ($forward) {
                 mapi_setprops($fwmessage, array(PR_ICON_INDEX => 262));
             } elseif ($reply) {
                 mapi_setprops($fwmessage, array(PR_ICON_INDEX => 261));
             }
             mapi_savechanges($fwmessage);
             $stream = mapi_openproperty($fwmessage, PR_BODY, IID_IStream, 0, 0);
             $fwbody = "";
             while (1) {
                 $data = mapi_stream_read($stream, 1024);
                 if (strlen($data) == 0) {
                     break;
                 }
                 $fwbody .= $data;
             }
             $stream = mapi_openproperty($fwmessage, PR_HTML, IID_IStream, 0, 0);
             $fwbody_html = "";
             while (1) {
                 $data = mapi_stream_read($stream, 1024);
                 if (strlen($data) == 0) {
                     break;
                 }
                 $fwbody_html .= $data;
             }
             if ($forward) {
                 // During a forward, we have to add the forward header ourselves. This is because
                 // normally the forwarded message is added as an attachment. However, we don't want this
                 // because it would be rather complicated to copy over the entire original message due
                 // to the lack of IMessage::CopyTo ..
                 $fwmessageprops = mapi_getprops($fwmessage, array(PR_SENT_REPRESENTING_NAME, PR_DISPLAY_TO, PR_DISPLAY_CC, PR_SUBJECT, PR_CLIENT_SUBMIT_TIME));
                 $fwheader = "\r\n\r\n";
                 $fwheader .= "-----Original Message-----\r\n";
                 if (isset($fwmessageprops[PR_SENT_REPRESENTING_NAME])) {
                     $fwheader .= "From: " . $fwmessageprops[PR_SENT_REPRESENTING_NAME] . "\r\n";
                 }
                 if (isset($fwmessageprops[PR_DISPLAY_TO]) && strlen($fwmessageprops[PR_DISPLAY_TO]) > 0) {
                     $fwheader .= "To: " . $fwmessageprops[PR_DISPLAY_TO] . "\r\n";
                 }
                 if (isset($fwmessageprops[PR_DISPLAY_CC]) && strlen($fwmessageprops[PR_DISPLAY_CC]) > 0) {
                     $fwheader .= "Cc: " . $fwmessageprops[PR_DISPLAY_CC] . "\r\n";
                 }
                 if (isset($fwmessageprops[PR_CLIENT_SUBMIT_TIME])) {
                     $fwheader .= "Sent: " . strftime("%x %X", $fwmessageprops[PR_CLIENT_SUBMIT_TIME]) . "\r\n";
                 }
                 if (isset($fwmessageprops[PR_SUBJECT])) {
                     $fwheader .= "Subject: " . $fwmessageprops[PR_SUBJECT] . "\r\n";
                 }
                 $fwheader .= "\r\n";
                 // add fwheader to body and body_html
                 $body .= $fwheader;
                 if (strlen($body_html) > 0) {
                     $body_html .= str_ireplace("\r\n", "<br>", $fwheader);
                 }
             }
             if (strlen($body) > 0) {
                 $body .= $fwbody;
             }
             if (strlen($body_html) > 0) {
                 $body_html .= $fwbody_html;
             }
         } else {
             debugLog("Unable to open item with id {$orig} for forward/reply");
         }
     }
     if ($forward) {
         // Add attachments from the original message in a forward
         $entryid = mapi_msgstore_entryidfromsourcekey($this->_defaultstore, hex2bin($parent), hex2bin($orig));
         $fwmessage = mapi_msgstore_openentry($this->_defaultstore, $entryid);
         $attachtable = mapi_message_getattachmenttable($fwmessage);
         $rows = mapi_table_queryallrows($attachtable, array(PR_ATTACH_NUM));
         foreach ($rows as $row) {
             if (isset($row[PR_ATTACH_NUM])) {
                 $attach = mapi_message_openattach($fwmessage, $row[PR_ATTACH_NUM]);
                 $newattach = mapi_message_createattach($mapimessage);
                 // Copy all attachments from old to new attachment
                 $attachprops = mapi_getprops($attach);
                 mapi_setprops($newattach, $attachprops);
                 if (isset($attachprops[mapi_prop_tag(PT_ERROR, mapi_prop_id(PR_ATTACH_DATA_BIN))])) {
                     // Data is in a stream
                     $srcstream = mapi_openpropertytostream($attach, PR_ATTACH_DATA_BIN);
                     $dststream = mapi_openpropertytostream($newattach, PR_ATTACH_DATA_BIN, MAPI_MODIFY | MAPI_CREATE);
                     while (1) {
                         $data = mapi_stream_read($srcstream, 4096);
                         if (strlen($data) == 0) {
                             break;
                         }
                         mapi_stream_write($dststream, $data);
                     }
                     mapi_stream_commit($dststream);
                 }
                 mapi_savechanges($newattach);
             }
         }
     }
     //set PR_INTERNET_CPID to 65001 (utf-8) if store supports it and to 1252 otherwise
     $internetcpid = 1252;
     if (defined('STORE_SUPPORTS_UNICODE') && STORE_SUPPORTS_UNICODE == true) {
         $internetcpid = 65001;
     }
     mapi_setprops($mapimessage, array(PR_BODY => $body, PR_INTERNET_CPID => $internetcpid));
     if (strlen($body_html) > 0) {
         mapi_setprops($mapimessage, array(PR_HTML => $body_html));
     }
     mapi_savechanges($mapimessage);
     mapi_message_submitmessage($mapimessage);
     return true;
 }
 function getCcAddressList()
 {
     return $this->struct->headers['cc'] ? Mail_RFC822::parseAddressList($this->struct->headers['cc']) : null;
 }
Beispiel #22
0
 /**
  * Adds the recipients to an email message from a RFC822 message headers.
  *
  * @param MIMEMessageHeader $headers
  * @param MAPIMessage $mapimessage
  */
 private function addRecipients($headers, &$mapimessage)
 {
     $toaddr = $ccaddr = $bccaddr = array();
     $Mail_RFC822 = new Mail_RFC822();
     if (isset($headers["to"])) {
         $toaddr = $Mail_RFC822->parseAddressList($headers["to"]);
     }
     if (isset($headers["cc"])) {
         $ccaddr = $Mail_RFC822->parseAddressList($headers["cc"]);
     }
     if (isset($headers["bcc"])) {
         $bccaddr = $Mail_RFC822->parseAddressList($headers["bcc"]);
     }
     if (empty($toaddr)) {
         throw new StatusException(sprintf("ZarafaBackend->SendMail(): 'To' address in RFC822 message not found or unparsable. To header: '%s'", isset($headers["to"]) ? $headers["to"] : ''), SYNC_COMMONSTATUS_MESSHASNORECIP);
     }
     // Add recipients
     $recips = array();
     foreach (array(MAPI_TO => $toaddr, MAPI_CC => $ccaddr, MAPI_BCC => $bccaddr) as $type => $addrlist) {
         foreach ($addrlist as $addr) {
             $mapirecip[PR_ADDRTYPE] = "SMTP";
             $mapirecip[PR_EMAIL_ADDRESS] = $addr->mailbox . "@" . $addr->host;
             if (isset($addr->personal) && strlen($addr->personal) > 0) {
                 $mapirecip[PR_DISPLAY_NAME] = u2wi($addr->personal);
             } else {
                 $mapirecip[PR_DISPLAY_NAME] = $mapirecip[PR_EMAIL_ADDRESS];
             }
             $mapirecip[PR_RECIPIENT_TYPE] = $type;
             $mapirecip[PR_ENTRYID] = mapi_createoneoff($mapirecip[PR_DISPLAY_NAME], $mapirecip[PR_ADDRTYPE], $mapirecip[PR_EMAIL_ADDRESS]);
             array_push($recips, $mapirecip);
         }
     }
     mapi_message_modifyrecipients($mapimessage, 0, $recips);
 }
 /**
  * explode recipient string
  * allowed seperators are ',' ';' ' '
  *
  * Returns an array with recipient objects
  *
  * @access	private
  *
  * @return array with recipient objects. array[i]->mailbox gets the mailbox
  * of the recipient. array[i]->host gets the host of the recipients. Returns
  * a PEAR_Error object, if exploding failed. Use is_a() to test, if the return
  * value is a PEAR_Error, then use $rcp->message to retrieve the error message.
  */
 function explodeRecipients($a_recipients, $use_pear = true)
 {
     $a_recipients = trim($a_recipients);
     // WHITESPACE IS NOT ALLOWED AS SEPERATOR
     #$a_recipients = preg_replace("/ /",",",$a_recipients);
     $a_recipients = preg_replace("/;/", ",", $a_recipients);
     if (ilMail::_usePearMail() && $use_pear == true) {
         if (strlen(trim($a_recipients)) > 0) {
             require_once './Services/PEAR/lib/Mail/RFC822.php';
             $parser = new Mail_RFC822();
             return $parser->parseAddressList($a_recipients, "ilias", false, true);
         } else {
             return array();
         }
     } else {
         foreach (explode(',', $a_recipients) as $tmp_rec) {
             if ($tmp_rec) {
                 $rcps[] = trim($tmp_rec);
             }
         }
         return is_array($rcps) ? $rcps : array();
     }
 }
Beispiel #24
0
    </fieldset>
    
  </fieldset>
</form>

<?php 
}
?>

<?php 
if (!empty($area)) {
    include_once 'Mail/RFC822.php';
    !isset($area_admin_email) ? $area_admin_email = '' : '';
    $emails = explode(',', $area_admin_email);
    $valid_email = TRUE;
    $email_validator = new Mail_RFC822();
    foreach ($emails as $email) {
        // if no email address is entered, this is OK, even if isValidInetAddress
        // does not return TRUE
        if (!$email_validator->isValidInetAddress($email, $strict = FALSE) && '' != $area_admin_email) {
            $valid_email = FALSE;
        }
    }
    //
    if (isset($change_area) && FALSE != $valid_email) {
        $sql = "UPDATE {$tbl_area} SET area_name='" . addslashes($area_name) . "', area_admin_email='" . addslashes($area_admin_email) . "' WHERE id={$area}";
        if (sql_command($sql) < 0) {
            fatal_error(0, get_vocab("update_area_failed") . sql_error());
        }
    }
    $res = sql_query("SELECT * FROM {$tbl_area} WHERE id={$area}");
Beispiel #25
0
 /**
  * Returns the mailbox address of a role.
  *
  * Example 1: Mailbox address for an ILIAS reserved role name
  * ----------------------------------------------------------
  * The il_crs_member_345 role of the course object "English Course 1" is 
  * returned as one of the following mailbox addresses:
  *
  * a)   Course Member <#member@[English Course 1]>
  * b)   Course Member <#il_crs_member_345@[English Course 1]>
  * c)   Course Member <#il_crs_member_345>
  *
  * Address a) is returned, if the title of the object is unique, and
  * if there is only one local role with the substring "member" defined for
  * the object.
  *
  * Address b) is returned, if the title of the object is unique, but 
  * there is more than one local role with the substring "member" in its title.
  *
  * Address c) is returned, if the title of the course object is not unique.
  *
  *
  * Example 2: Mailbox address for a manually defined role name
  * -----------------------------------------------------------
  * The "Admin" role of the category object "Courses" is 
  * returned as one of the following mailbox addresses:
  *
  * a)   Course Administrator <#Admin@Courses>
  * b)   Course Administrator <#Admin>
  * c)   Course Adminstrator <#il_role_34211>
  *
  * Address a) is returned, if the title of the object is unique, and
  * if there is only one local role with the substring "Admin" defined for
  * the course object.
  *
  * Address b) is returned, if the title of the object is not unique, but 
  * the role title is unique.
  *
  * Address c) is returned, if neither the role title nor the title of the
  * course object is unique. 
  *
  *
  * Example 3: Mailbox address for a manually defined role title that can
  *            contains special characters in the local-part of a 
  *            mailbox address
  * --------------------------------------------------------------------
  * The "Author Courses" role of the category object "Courses" is 
  * returned as one of the following mailbox addresses:
  *
  * a)   "#Author Courses"@Courses
  * b)   Author Courses <#il_role_34234>
  *
  * Address a) is returned, if the title of the role is unique.
  *
  * Address b) is returned, if neither the role title nor the title of the
  * course object is unique, or if the role title contains a quote or a
  * backslash.
  *
  *
  * @param int a role id
  * @param boolean is_localize whether mailbox addresses should be localized
  * @return	String mailbox address or null, if role does not exist.
  * @todo refactor rolf
  */
 function getRoleMailboxAddress($a_role_id, $is_localize = true)
 {
     global $log, $lng, $ilDB;
     include_once "Services/Mail/classes/class.ilMail.php";
     if (ilMail::_usePearMail()) {
         // Retrieve the role title and the object title.
         $query = "SELECT rdat.title role_title,odat.title object_title, " . " oref.ref_id object_ref " . "FROM object_data rdat " . "JOIN rbac_fa fa ON fa.rol_id = rdat.obj_id " . "JOIN tree rtree ON rtree.child = fa.parent " . "JOIN object_reference oref ON oref.ref_id = rtree.parent " . "JOIN object_data odat ON odat.obj_id = oref.obj_id " . "WHERE rdat.obj_id = " . $this->ilDB->quote($a_role_id, 'integer') . " " . "AND fa.assign = 'y' ";
         $r = $ilDB->query($query);
         if (!($row = $ilDB->fetchObject($r))) {
             //$log->write('class.ilRbacReview->getMailboxAddress('.$a_role_id.'): error role does not exist');
             return null;
             // role does not exist
         }
         $object_title = $row->object_title;
         $object_ref = $row->object_ref;
         $role_title = $row->role_title;
         // In a perfect world, we could use the object_title in the
         // domain part of the mailbox address, and the role title
         // with prefix '#' in the local part of the mailbox address.
         $domain = $object_title;
         $local_part = $role_title;
         // Determine if the object title is unique
         $q = "SELECT COUNT(DISTINCT dat.obj_id) count " . "FROM object_data dat " . "JOIN object_reference ref ON ref.obj_id = dat.obj_id " . "JOIN tree ON tree.child = ref.ref_id " . "WHERE title = " . $this->ilDB->quote($object_title, 'text') . " " . "AND tree.tree = 1 ";
         $r = $this->ilDB->query($q);
         $row = $r->fetchRow(DB_FETCHMODE_OBJECT);
         // If the object title is not unique, we get rid of the domain.
         if ($row->count > 1) {
             $domain = null;
         }
         // If the domain contains illegal characters, we get rid of it.
         //if (domain != null && preg_match('/[\[\]\\]|[\x00-\x1f]/',$domain))
         // Fix for Mantis Bug: 7429 sending mail fails because of brakets
         // Fix for Mantis Bug: 9978 sending mail fails because of semicolon
         if ($domain != null && preg_match('/[\\[\\]\\]|[\\x00-\\x1f]|[\\x28-\\x29]|[;]/', $domain)) {
             $domain = null;
         }
         // If the domain contains special characters, we put square
         //   brackets around it.
         if ($domain != null && (preg_match('/[()<>@,;:\\".\\[\\]]/', $domain) || preg_match('/[^\\x21-\\x8f]/', $domain))) {
             $domain = '[' . $domain . ']';
         }
         // If the role title is one of the ILIAS reserved role titles,
         //     we can use a shorthand version of it for the local part
         //     of the mailbox address.
         if (strpos($role_title, 'il_') === 0 && $domain != null) {
             $unambiguous_role_title = $role_title;
             $pos = strpos($role_title, '_', 3) + 1;
             $local_part = substr($role_title, $pos, strrpos($role_title, '_') - $pos);
         } else {
             $unambiguous_role_title = 'il_role_' . $a_role_id;
         }
         // Determine if the local part is unique. If we don't have a
         // domain, the local part must be unique within the whole repositry.
         // If we do have a domain, the local part must be unique for that
         // domain.
         if ($domain == null) {
             $q = "SELECT COUNT(DISTINCT dat.obj_id) count " . "FROM object_data dat " . "JOIN object_reference ref ON ref.obj_id = dat.obj_id " . "JOIN tree ON tree.child = ref.ref_id " . "WHERE title = " . $this->ilDB->quote($local_part, 'text') . " " . "AND tree.tree = 1 ";
         } else {
             $q = "SELECT COUNT(rd.obj_id) count " . "FROM object_data rd " . "JOIN rbac_fa fa ON rd.obj_id = fa.rol_id " . "JOIN tree t ON t.child = fa.parent " . "WHERE fa.assign = 'y' " . "AND t.parent = " . $this->ilDB->quote($object_ref, 'integer') . " " . "AND rd.title LIKE " . $this->ilDB->quote('%' . preg_replace('/([_%])/', '\\\\$1', $local_part) . '%', 'text') . " ";
         }
         $r = $this->ilDB->query($q);
         $row = $r->fetchRow(DB_FETCHMODE_OBJECT);
         // if the local_part is not unique, we use the unambiguous role title
         //   instead for the local part of the mailbox address
         if ($row->count > 1) {
             $local_part = $unambiguous_role_title;
         }
         $use_phrase = true;
         // If the local part contains illegal characters, we use
         //     the unambiguous role title instead.
         if (preg_match('/[\\"\\x00-\\x1f]/', $local_part)) {
             $local_part = $unambiguous_role_title;
         } else {
             if (!preg_match('/^[\\x00-\\x7E]+$/i', $local_part)) {
                 // 2013-12-05: According to #12283, we do not accept umlauts in the local part
                 $local_part = $unambiguous_role_title;
                 $use_phrase = false;
             }
         }
         // Add a "#" prefix to the local part
         $local_part = '#' . $local_part;
         // Put quotes around the role title, if needed
         if (preg_match('/[()<>@,;:.\\[\\]\\x20]/', $local_part)) {
             $local_part = '"' . $local_part . '"';
         }
         $mailbox = $domain == null ? $local_part : $local_part . '@' . $domain;
         if ($is_localize) {
             if (substr($role_title, 0, 3) == 'il_') {
                 $phrase = $lng->txt(substr($role_title, 0, strrpos($role_title, '_')));
             } else {
                 $phrase = $role_title;
             }
             if ($use_phrase) {
                 // make phrase RFC 822 conformant:
                 // - strip excessive whitespace
                 // - strip special characters
                 $phrase = preg_replace('/\\s\\s+/', ' ', $phrase);
                 $phrase = preg_replace('/[()<>@,;:\\".\\[\\]]/', '', $phrase);
                 $mailbox = $phrase . ' <' . $mailbox . '>';
             }
         }
         require_once './Services/PEAR/lib/Mail/RFC822.php';
         $obj = new Mail_RFC822($mailbox, 'ilias');
         if (@$obj->parseAddressList() instanceof PEAR_Error) {
             $q = "SELECT title " . "FROM object_data " . "WHERE obj_id = " . $this->ilDB->quote($a_role_id, 'integer');
             $r = $this->ilDB->query($q);
             if ($row = $r->fetchRow(DB_FETCHMODE_OBJECT)) {
                 return '#' . $row->title;
             } else {
                 return null;
             }
         }
         return $mailbox;
     } else {
         $q = "SELECT title " . "FROM object_data " . "WHERE obj_id = " . $this->ilDB->quote($a_role_id, 'integer');
         $r = $this->ilDB->query($q);
         if ($row = $r->fetchRow(DB_FETCHMODE_OBJECT)) {
             return '#' . $row->title;
         } else {
             return null;
         }
     }
 }
Beispiel #26
0
 function register(&$data, $auto_activate = false)
 {
     $session = Session::singletone();
     $db = Database::singletone()->db();
     if (empty($data['user_login'])) {
         throw new Exception("Nie można zarejestrować konta. Musisz podać login.");
     }
     if (empty($data['user_pass1']) || empty($data['user_pass2'])) {
         throw new Exception("Nie można zarejestrować konta. Hasło nie może być puste.");
     }
     if (empty($data['user_email'])) {
         throw new Exception("Nie można zarejestrować konta. Musisz podać email.");
     }
     $addr = Mail_RFC822::parseAddressList($data['user_email'], "");
     if (empty($addr)) {
         throw new Exception("Nie można zarejestrować konta. Podany adres email jest nieprawidłowy.");
     }
     if ($data['user_pass1'] != $data['user_pass2']) {
         throw new Exception("Nie można zarejestrować konta. Podane hasła różnią się");
     }
     $user_login = trim($data['user_login']);
     $user_pass1 = $data['user_pass1'];
     $user_pass2 = $data['user_pass2'];
     $user_email = trim($data['user_email']);
     $user_title = Config::get('default_user_title');
     $user_level = Config::get('default_user_level', 0);
     $sth = $db->prepare("SELECT COUNT(*) AS cnt FROM phph_users WHERE user_login = :user_login");
     $sth->bindParam(":user_login", $user_login);
     $sth->execute();
     $cnt = $sth->fetchColumn(0);
     $sth = null;
     if ($cnt != 0) {
         throw new Exception("Nie można zarejestrować konta. Podany login jest już zajęty.");
     }
     $sth = $db->prepare("INSERT INTO phph_users (user_login, user_pass, user_email, user_registered, user_activation, user_title, user_level, user_activated) VALUES " . "(:user_login, :user_pass, :user_email, :user_registered, :user_activation, :user_title, :user_level, :user_activated)");
     $sth->bindParam(":user_login", $user_login);
     $sth->bindValue(":user_pass", md5($user_pass1));
     $sth->bindParam(":user_email", $user_email);
     $sth->bindParam(":user_title", $user_title);
     $sth->bindParam(":user_level", $user_level);
     $sth->bindValue(":user_registered", time());
     $sth->bindValue(":user_activation", md5(uniqid($user_login)));
     if ($auto_activate) {
         $sth->bindValue(":user_activated", time());
     } else {
         $sth->bindValue(":user_activated", 0);
     }
     $sth->execute();
     $sth = null;
     $this->_uid = $db->lastInsertId();
     $this->updateDBData();
     return $this->_uid;
 }
Beispiel #27
0
 function parseAddressList($address)
 {
     return Mail_RFC822::parseAddressList($address, null, null, false);
 }
Beispiel #28
0
 /**
  * Take a set of recipients and parse them, returning an array of
  * bare addresses (forward paths) that can be passed to sendmail
  * or an smtp server with the rcpt to: command.
  *
  * @param mixed Either a comma-seperated list of recipients
  *              (RFC822 compliant), or an array of recipients,
  *              each RFC822 valid.
  *
  * @return mixed An array of forward paths (bare addresses) or a PEAR_Error
  *               object if the address list could not be parsed.
  * @access private
  */
 function parseRecipients($recipients)
 {
     // if we're passed an array, assume addresses are valid and
     // implode them before parsing.
     if (is_array($recipients)) {
         $recipients = implode(', ', $recipients);
     }
     // Parse recipients, leaving out all personal info. This is
     // for smtp recipients, etc. All relevant personal information
     // should already be in the headers.
     $parser = new Mail_RFC822();
     $addresses = $parser->parseAddressList($recipients, 'localhost', false);
     // If parseAddressList() returned a PEAR_Error object, just return it.
     //if (is_a($addresses, 'PEAR_Error')) {
     if ($addresses === false) {
         return $addresses;
     }
     $recipients = array();
     if (is_array($addresses)) {
         foreach ($addresses as $ob) {
             $recipients[] = $ob->mailbox . '@' . $ob->host;
         }
     }
     // Remove duplicated
     $recipients = array_unique($recipients);
     return $recipients;
 }
Beispiel #29
0
 /**
  * Returns the actual SyncXXX object type.
  *
  * @param string            $folderid           id of the parent folder
  * @param string            $id                 id of the message
  * @param ContentParameters $contentparameters  parameters of the requested message (truncation, mimesupport etc)
  *
  * @access public
  * @return object/false     false if the message could not be retrieved
  */
 public function GetMessage($folderid, $id, $truncsize, $mimesupport = 0)
 {
     if ($folderid != 'root') {
         return false;
     }
     $fn = $this->findMessage($id);
     // Get flags, etc
     $stat = $this->StatMessage($folderid, $id);
     // Parse e-mail
     $rfc822 = file_get_contents($this->getPath() . "/" . $fn);
     $message = Mail_mimeDecode::decode(array('decode_headers' => true, 'decode_bodies' => true, 'include_bodies' => true, 'input' => $rfc822, 'crlf' => "\n", 'charset' => 'utf-8'));
     $output = new SyncMail();
     $output->body = str_replace("\n", "\r\n", $this->getBody($message));
     $output->bodysize = strlen($output->body);
     $output->bodytruncated = 0;
     // We don't implement truncation in this backend
     $output->datereceived = $this->parseReceivedDate($message->headers["received"][0]);
     $output->messageclass = "IPM.Note";
     $output->subject = $message->headers["subject"];
     $output->read = $stat["flags"];
     $output->from = $message->headers["from"];
     $Mail_RFC822 = new Mail_RFC822();
     $toaddr = $ccaddr = $replytoaddr = array();
     if (isset($message->headers["to"])) {
         $toaddr = $Mail_RFC822->parseAddressList($message->headers["to"]);
     }
     if (isset($message->headers["cc"])) {
         $ccaddr = $Mail_RFC822->parseAddressList($message->headers["cc"]);
     }
     if (isset($message->headers["reply_to"])) {
         $replytoaddr = $Mail_RFC822->parseAddressList($message->headers["reply_to"]);
     }
     $output->to = array();
     $output->cc = array();
     $output->reply_to = array();
     foreach (array("to" => $toaddr, "cc" => $ccaddr, "reply_to" => $replytoaddr) as $type => $addrlist) {
         foreach ($addrlist as $addr) {
             $address = $addr->mailbox . "@" . $addr->host;
             $name = $addr->personal;
             if (!isset($output->displayto) && $name != "") {
                 $output->displayto = $name;
             }
             if ($name == "" || $name == $address) {
                 $fulladdr = w2u($address);
             } else {
                 if (substr($name, 0, 1) != '"' && substr($name, -1) != '"') {
                     $fulladdr = "\"" . w2u($name) . "\" <" . w2u($address) . ">";
                 } else {
                     $fulladdr = w2u($name) . " <" . w2u($address) . ">";
                 }
             }
             array_push($output->{$type}, $fulladdr);
         }
     }
     // convert mime-importance to AS-importance
     if (isset($message->headers["x-priority"])) {
         $mimeImportance = preg_replace("/\\D+/", "", $message->headers["x-priority"]);
         if ($mimeImportance > 3) {
             $output->importance = 0;
         }
         if ($mimeImportance == 3) {
             $output->importance = 1;
         }
         if ($mimeImportance < 3) {
             $output->importance = 2;
         }
     }
     // Attachments are only searched in the top-level part
     $n = 0;
     if (isset($message->parts)) {
         foreach ($message->parts as $part) {
             if ($part->ctype_primary == "application") {
                 $attachment = new SyncAttachment();
                 $attachment->attsize = strlen($part->body);
                 if (isset($part->d_parameters['filename'])) {
                     $attname = $part->d_parameters['filename'];
                 } else {
                     if (isset($part->ctype_parameters['name'])) {
                         $attname = $part->ctype_parameters['name'];
                     } else {
                         if (isset($part->headers['content-description'])) {
                             $attname = $part->headers['content-description'];
                         } else {
                             $attname = "unknown attachment";
                         }
                     }
                 }
                 $attachment->displayname = $attname;
                 $attachment->attname = $id . ":" . $n;
                 $attachment->attmethod = 1;
                 $attachment->attoid = isset($part->headers['content-id']) ? $part->headers['content-id'] : "";
                 array_push($output->attachments, $attachment);
             }
             $n++;
         }
     }
     return $output;
 }
Beispiel #30
0
 /**
  * Implements Mail_mail::send() function using php's built-in mail()
  * command.
  * 
  * @param mixed $recipients Either a comma-seperated list of recipients
  *              (RFC822 compliant), or an array of recipients,
  *              each RFC822 valid. This may contain recipients not
  *              specified in the headers, for Bcc:, resending
  *              messages, etc.
  *
  * @param array $headers The array of headers to send with the mail, in an
  *              associative array, where the array key is the
  *              header name (ie, 'Subject'), and the array value
  *              is the header value (ie, 'test'). The header
  *              produced from those values would be 'Subject:
  *              test'.
  *
  * @param string $body The full text of the message body, including any
  *               Mime parts, etc.
  *
  * @return mixed Returns true on success, or a PEAR_Error
  *               containing a descriptive error message on
  *               failure.
  * @access public
  */
 function send($recipients, $headers, $body)
 {
     // if we're passed an array of recipients, implode it.
     if (is_array($recipients)) {
         $recipients = implode(', ', $recipients);
     }
     // get the Subject out of the headers array so that we can
     // pass it as a seperate argument to mail().
     $subject = '';
     if (isset($headers['Subject'])) {
         $subject = $headers['Subject'];
         unset($headers['Subject']);
     }
     // flatten the headers out.
     list(, $text_headers) = Mail::prepareHeaders($headers);
     include_once 'Mail/RFC822.php';
     $addresses = Mail_RFC822::parseAddressList($headers['From'], 'localhost', false);
     $from = $addresses[0]->mailbox . '@' . $addresses[0]->host;
     return mail($recipients, $subject, $body, $text_headers, "-f" . $from . " " . $this->_params);
 }