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


PHP CRM_Utils_Mail::logger方法代码示例

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


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

示例1: send

 /**
  * Implements Mail::send() function using the sendmail
  * command-line binary.
  *
  * @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 (defined('CIVICRM_MAIL_LOG')) {
         require_once 'CRM/Utils/Mail.php';
         CRM_Utils_Mail::logger($recipients, $headers, $body);
         return true;
     }
     if (!is_array($headers)) {
         return PEAR::raiseError('$headers must be an array');
     }
     $result = $this->_sanitizeHeaders($headers);
     if (is_a($result, 'PEAR_Error')) {
         return $result;
     }
     $recipients = $this->parseRecipients($recipients);
     if (is_a($recipients, 'PEAR_Error')) {
         return $recipients;
     }
     $recipients = implode(' ', array_map('escapeshellarg', $recipients));
     $headerElements = $this->prepareHeaders($headers);
     if (is_a($headerElements, 'PEAR_Error')) {
         return $headerElements;
     }
     list($from, $text_headers) = $headerElements;
     /* Since few MTAs are going to allow this header to be forged
      * unless it's in the MAIL FROM: exchange, we'll use
      * Return-Path instead of From: if it's set. */
     if (!empty($headers['Return-Path'])) {
         $from = $headers['Return-Path'];
     }
     if (!isset($from)) {
         return PEAR::raiseError('No from address given.');
     } elseif (strpos($from, ' ') !== false || strpos($from, ';') !== false || strpos($from, '&') !== false || strpos($from, '`') !== false) {
         return PEAR::raiseError('From address specified with dangerous characters.');
     }
     $from = escapeshellarg($from);
     // Security bug #16200
     $mail = @popen($this->sendmail_path . (!empty($this->sendmail_args) ? ' ' . $this->sendmail_args : '') . " -f{$from} -- {$recipients}", 'w');
     if (!$mail) {
         return PEAR::raiseError('Failed to open sendmail [' . $this->sendmail_path . '] for execution.');
     }
     // Write the headers following by two newlines: one to end the headers
     // section and a second to separate the headers block from the body.
     fputs($mail, $text_headers . $this->sep . $this->sep);
     fputs($mail, $body);
     $result = pclose($mail);
     if (version_compare(phpversion(), '4.2.3') == -1) {
         // With older php versions, we need to shift the pclose
         // result to get the exit code.
         $result = $result >> 8 & 0xff;
     }
     if ($result != 0) {
         return PEAR::raiseError('sendmail returned error code ' . $result, $result);
     }
     return true;
 }
开发者ID:DaveNascimento,项目名称:civicrm-packages,代码行数:81,代码来源:sendmail.php

示例2: send

 /**
  * 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 (defined('CIVICRM_MAIL_LOG')) {
         require_once 'CRM/Utils/Mail.php';
         CRM_Utils_Mail::logger($recipients, $headers, $body);
         return true;
     }
     $this->_sanitizeHeaders($headers);
     // 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']);
     }
     /*
      * Also remove the To: header.  The mail() function will add its own
      * To: header based on the contents of $recipients.
      */
     unset($headers['To']);
     // Flatten the headers out.
     $headerElements = $this->prepareHeaders($headers);
     if (PEAR::isError($headerElements)) {
         return $headerElements;
     }
     list(, $text_headers) = $headerElements;
     /*
      * We only use mail()'s optional fifth parameter if the additional
      * parameters have been provided and we're not running in safe mode.
      */
     if (empty($this->_params) || ini_get('safe_mode')) {
         $result = mail($recipients, $subject, $body, $text_headers);
     } else {
         $result = mail($recipients, $subject, $body, $text_headers, $this->_params);
     }
     /*
      * If the mail() function returned failure, we need to create a
      * PEAR_Error object and return it instead of the boolean result.
      */
     if ($result === false) {
         $result = PEAR::raiseError('mail() returned failure');
     }
     return $result;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:74,代码来源:mail.php

示例3: send

 /**
  * Implements Mail::send() function using SMTP.
  *
  * @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 (e.g., 'Subject'), and the array value
  *              is the header value (e.g., '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 (defined('CIVICRM_MAIL_LOG')) {
         require_once 'CRM/Utils/Mail.php';
         CRM_Utils_Mail::logger($recipients, $headers, $body);
         return true;
     }
     /* If we don't already have an SMTP object, create one. */
     $result =& $this->getSMTPObject();
     if (PEAR::isError($result)) {
         return $result;
     }
     if (!is_array($headers)) {
         return PEAR::raiseError('$headers must be an array');
     }
     $this->_sanitizeHeaders($headers);
     $headerElements = $this->prepareHeaders($headers);
     if (is_a($headerElements, 'PEAR_Error')) {
         $this->_smtp->rset();
         return $headerElements;
     }
     list($from, $textHeaders) = $headerElements;
     /* Since few MTAs are going to allow this header to be forged
      * unless it's in the MAIL FROM: exchange, we'll use
      * Return-Path instead of From: if it's set. */
     if (!empty($headers['Return-Path'])) {
         $from = $headers['Return-Path'];
     }
     if (!isset($from)) {
         $this->_smtp->rset();
         return PEAR::raiseError('No From: address has been provided', PEAR_MAIL_SMTP_ERROR_FROM);
     }
     $params = null;
     if (!empty($this->_extparams)) {
         foreach ($this->_extparams as $key => $val) {
             $params .= ' ' . $key . (is_null($val) ? '' : '=' . $val);
         }
     }
     if (PEAR::isError($res = $this->_smtp->mailFrom($from, ltrim($params)))) {
         $error = $this->_error("Failed to set sender: {$from}", $res);
         $this->_smtp->rset();
         return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_SENDER);
     }
     $recipients = $this->parseRecipients($recipients);
     if (is_a($recipients, 'PEAR_Error')) {
         $this->_smtp->rset();
         return $recipients;
     }
     foreach ($recipients as $recipient) {
         $res = $this->_smtp->rcptTo($recipient);
         if (is_a($res, 'PEAR_Error')) {
             $error = $this->_error("Failed to add recipient: {$recipient}", $res);
             $this->_smtp->rset();
             return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_RECIPIENT);
         }
     }
     /* Send the message's headers and the body as SMTP data. */
     $res = $this->_smtp->data($textHeaders . "\r\n\r\n" . $body);
     list(, $args) = $this->_smtp->getResponse();
     if (preg_match("/Ok: queued as (.*)/", $args, $queued)) {
         $this->queued_as = $queued[1];
     }
     /* we need the greeting; from it we can extract the authorative name of the mail server we've really connected to.
      * ideal if we're connecting to a round-robin of relay servers and need to track which exact one took the email */
     $this->greeting = $this->_smtp->getGreeting();
     if (is_a($res, 'PEAR_Error')) {
         $error = $this->_error('Failed to send data', $res);
         $this->_smtp->rset();
         return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_DATA);
     }
     /* If persistent connections are disabled, destroy our SMTP object. */
     if ($this->persist === false) {
         $this->disconnect();
     }
     return true;
 }
开发者ID:DaveNascimento,项目名称:civicrm-packages,代码行数:100,代码来源:smtp.php

示例4: send

 /**
  * Implements Mail::send() function using the sendmail
  * command-line binary.
  *
  * @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 (defined('CIVICRM_MAIL_LOG')) {
         require_once 'CRM/Utils/Mail.php';
         CRM_Utils_Mail::logger($recipients, $headers, $body);
         return true;
     }
     $recipients = $this->parseRecipients($recipients);
     if (PEAR::isError($recipients)) {
         return $recipients;
     }
     $recipients = escapeShellCmd(implode(' ', $recipients));
     $this->_sanitizeHeaders($headers);
     $headerElements = $this->prepareHeaders($headers);
     if (PEAR::isError($headerElements)) {
         return $headerElements;
     }
     list($from, $text_headers) = $headerElements;
     // use Return-Path for SMTP envelope’s FROM address (if set), CRM-5946
     if (!empty($headers['Return-Path'])) {
         $from = $headers['Return-Path'];
     }
     if (!isset($from)) {
         return PEAR::raiseError('No from address given.');
     } elseif (strpos($from, ' ') !== false || strpos($from, ';') !== false || strpos($from, '&') !== false || strpos($from, '`') !== false) {
         return PEAR::raiseError('From address specified with dangerous characters.');
     }
     $from = escapeShellCmd($from);
     $mail = @popen($this->sendmail_path . (!empty($this->sendmail_args) ? ' ' . $this->sendmail_args : '') . " -f{$from} -- {$recipients}", 'w');
     if (!$mail) {
         return PEAR::raiseError('Failed to open sendmail [' . $this->sendmail_path . '] for execution.');
     }
     // Write the headers following by two newlines: one to end the headers
     // section and a second to separate the headers block from the body.
     fputs($mail, $text_headers . $this->sep . $this->sep);
     fputs($mail, $body);
     $result = pclose($mail);
     if (version_compare(phpversion(), '4.2.3') == -1) {
         // With older php versions, we need to shift the pclose
         // result to get the exit code.
         $result = $result >> 8 & 0xff;
     }
     if ($result != 0) {
         return PEAR::raiseError('sendmail returned error code ' . $result, $result);
     }
     return true;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:72,代码来源:sendmail.php

示例5: send

 /**
  * 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 (defined('CIVICRM_MAIL_LOG')) {
         CRM_Utils_Mail::logger($recipients, $headers, $body);
         if (!defined('CIVICRM_MAIL_LOG_AND SEND')) {
             return true;
         }
     }
     if (!is_array($headers)) {
         return PEAR::raiseError('$headers must be an array');
     }
     $result = $this->_sanitizeHeaders($headers);
     if (is_a($result, 'PEAR_Error')) {
         return $result;
     }
     // 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']);
     }
     // Also remove the To: header.  The mail() function will add its own
     // To: header based on the contents of $recipients.
     unset($headers['To']);
     // Flatten the headers out.
     $headerElements = $this->prepareHeaders($headers);
     if (is_a($headerElements, 'PEAR_Error')) {
         return $headerElements;
     }
     list($from, $text_headers) = $headerElements;
     // use Return-Path for SMTP envelope’s FROM address (if set), CRM-5946
     if (!empty($headers['Return-Path'])) {
         $from = $headers['Return-Path'];
     }
     $this->_params = "-f" . $from;
     // We only use mail()'s optional fifth parameter if the additional
     // parameters have been provided and we're not running in safe mode.
     if (empty($this->_params) || ini_get('safe_mode')) {
         $result = mail($recipients, $subject, $body, $text_headers);
     } else {
         $result = mail($recipients, $subject, $body, $text_headers, $this->_params);
     }
     // If the mail() function returned failure, we need to create a
     // PEAR_Error object and return it instead of the boolean result.
     if ($result === false) {
         $result = PEAR::raiseError('mail() returned failure');
     }
     return $result;
 }
开发者ID:kidaa30,项目名称:yes,代码行数:80,代码来源:mail.php

示例6: send

 /**
  * Implements Mail::send() function using SMTP.
  *
  * @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 (e.g., 'Subject'), and the array value
  *              is the header value (e.g., '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 (defined('CIVICRM_MAIL_LOG')) {
         require_once 'CRM/Utils/Mail.php';
         CRM_Utils_Mail::logger($recipients, $headers, $body);
         return true;
     }
     include_once 'Net/SMTP.php';
     /* If we don't already have an SMTP object, create one. */
     if (is_object($this->_smtp) === false) {
         $this->_smtp =& new Net_SMTP($this->host, $this->port, $this->localhost);
         /* If we still don't have an SMTP object at this point, fail. */
         if (is_object($this->_smtp) === false) {
             return PEAR::raiseError('Failed to create a Net_SMTP object', PEAR_MAIL_SMTP_ERROR_CREATE);
         }
         /* Configure the SMTP connection. */
         if ($this->debug) {
             $this->_smtp->setDebug(true);
         }
         /* Attempt to connect to the configured SMTP server. */
         if (PEAR::isError($res = $this->_smtp->connect($this->timeout))) {
             $error = $this->_error('Failed to connect to ' . $this->host . ':' . $this->port, $res);
             return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_CONNECT);
         }
         /* Attempt to authenticate if authentication has been enabled. */
         if ($this->auth) {
             $method = is_string($this->auth) ? $this->auth : '';
             if (PEAR::isError($res = $this->_smtp->auth($this->username, $this->password, $method))) {
                 $error = $this->_error("{$method} authentication failure", $res);
                 $this->_smtp->rset();
                 return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_AUTH);
             }
         }
     }
     $this->_sanitizeHeaders($headers);
     $headerElements = $this->prepareHeaders($headers);
     if (PEAR::isError($headerElements)) {
         $this->_smtp->rset();
         return $headerElements;
     }
     list($from, $textHeaders) = $headerElements;
     /* Since few MTAs are going to allow this header to be forged
      * unless it's in the MAIL FROM: exchange, we'll use
      * Return-Path instead of From: if it's set. */
     if (!empty($headers['Return-Path'])) {
         $from = $headers['Return-Path'];
     }
     if (!isset($from)) {
         $this->_smtp->rset();
         return PEAR::raiseError('No From: address has been provided', PEAR_MAIL_SMTP_ERROR_FROM);
     }
     $args['verp'] = $this->verp;
     if (PEAR::isError($res = $this->_smtp->mailFrom($from, $args))) {
         $error = $this->_error("Failed to set sender: {$from}", $res);
         $this->_smtp->rset();
         return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_SENDER);
     }
     $recipients = $this->parseRecipients($recipients);
     if (PEAR::isError($recipients)) {
         $this->_smtp->rset();
         return $recipients;
     }
     foreach ($recipients as $recipient) {
         if (PEAR::isError($res = $this->_smtp->rcptTo($recipient))) {
             $error = $this->_error("Failed to add recipient: {$recipient}", $res);
             $this->_smtp->rset();
             return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_RECIPIENT);
         }
     }
     /* Send the message's headers and the body as SMTP data. */
     if (PEAR::isError($res = $this->_smtp->data($textHeaders . "\r\n\r\n" . $body))) {
         $error = $this->_error('Failed to send data', $res);
         $this->_smtp->rset();
         return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_DATA);
     }
     /* If persistent connections are disabled, destroy our SMTP object. */
//.........这里部分代码省略.........
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:smtp.php


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