Skip to content

Instantly share code, notes, and snippets.

@seamuslee001
Created December 29, 2018 23:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seamuslee001/2f44ca05b931a2886c6013bd6a0932fd to your computer and use it in GitHub Desktop.
Save seamuslee001/2f44ca05b931a2886c6013bd6a0932fd to your computer and use it in GitHub Desktop.
--- ../../../packages/Mail.php 2018-12-13 13:10:16.296029724 +1100
+++ Mail.php 2018-12-30 10:27:31.580583861 +1100
@@ -1,32 +1,34 @@
<?php
/**
- * PEAR's Mail:: interface.
+ * PEAR's Mail:: interface.
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE:
*
- * Copyright (c) 2002-2007, Richard Heyes
+ * Copyright (c) 1997-2017, Chuck Hagenbuch & Richard Heyes
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
- * o Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * o Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * o The names of the authors may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
@@ -37,9 +39,9 @@
* @category Mail
* @package Mail
* @author Chuck Hagenbuch <chuck@horde.org>
- * @copyright 1997-2010 Chuck Hagenbuch
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Mail.php 294747 2010-02-08 08:18:33Z clockwerx $
+ * @copyright 1997-2017 Chuck Hagenbuch
+ * @license http://opensource.org/licenses/BSD-3-Clause New BSD License
+ * @version CVS: $Id$
* @link http://pear.php.net/package/Mail/
*/
@@ -50,8 +52,7 @@
* mailers under the PEAR hierarchy, and provides supporting functions
* useful in multiple mailer backends.
*
- * @access public
- * @version $Revision: 294747 $
+ * @version $Revision$
* @package Mail
*/
class Mail
@@ -60,7 +61,7 @@
* Line terminator used for separating header lines.
* @var string
*/
- var $sep = "\r\n";
+ public $sep = "\r\n";
/**
* Provides an interface for generating Mail:: objects of various
@@ -68,10 +69,10 @@
*
* @param string $driver The kind of Mail:: object to instantiate.
* @param array $params The parameters to pass to the Mail:: object.
+ *
* @return object Mail a instance of the driver class or if fails a PEAR Error
- * @access public
*/
- static function &factory($driver, $params = array())
+ public static function factory($driver, $params = array())
{
$driver = strtolower($driver);
@include_once 'Mail/' . $driver . '.php';
@@ -108,10 +109,9 @@
* containing a descriptive error message on
* failure.
*
- * @access public
* @deprecated use Mail_mail::send instead
*/
- function send($recipients, $headers, $body)
+ public function send($recipients, $headers, $body)
{
if (!is_array($headers)) {
return PEAR::raiseError('$headers must be an array');
@@ -147,10 +147,8 @@
* filter is to prevent mail injection attacks.
*
* @param array $headers The associative array of headers to sanitize.
- *
- * @access private
*/
- function _sanitizeHeaders(&$headers)
+ protected function _sanitizeHeaders(&$headers)
{
foreach ($headers as $key => $value) {
$headers[$key] =
@@ -177,9 +175,8 @@
* otherwise returns an array containing two
* elements: Any From: address found in the headers,
* and the plain text version of the headers.
- * @access private
*/
- function prepareHeaders($headers)
+ protected function prepareHeaders($headers)
{
$lines = array();
$from = null;
@@ -239,9 +236,8 @@
*
* @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)
+ protected function parseRecipients($recipients)
{
include_once 'Mail/RFC822.php';
@@ -254,9 +250,8 @@
// Parse recipients, leaving out all personal info. This is
// for smtp recipients, etc. All relevant personal information
// should already be in the headers.
-
- $mail_object = new Mail_RFC822($recipients, 'localhost', false);
- $addresses = $mail_object->parseAddressList();
+ $Mail_RFC822 = new Mail_RFC822();
+ $addresses = $Mail_RFC822->parseAddressList($recipients, 'localhost', false);
// If parseAddressList() returned a PEAR_Error object, just return it.
if (is_a($addresses, 'PEAR_Error')) {
--- ../../../../packages/Mail/mail.php 2018-12-13 13:10:15.300020914 +1100
+++ mail.php 2018-12-30 10:27:31.584583779 +1100
@@ -2,31 +2,33 @@
/**
* internal PHP-mail() implementation of the PEAR Mail:: interface.
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE:
*
- * Copyright (c) 2010 Chuck Hagenbuch
+ * Copyright (c) 2010-2017, Chuck Hagenbuch
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
- * o Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * o Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * o The names of the authors may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
@@ -37,16 +39,16 @@
* @category Mail
* @package Mail
* @author Chuck Hagenbuch <chuck@horde.org>
- * @copyright 2010 Chuck Hagenbuch
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: mail.php 294747 2010-02-08 08:18:33Z clockwerx $
+ * @copyright 2010-2017 Chuck Hagenbuch
+ * @license http://opensource.org/licenses/BSD-3-Clause New BSD License
+ * @version CVS: $Id$
* @link http://pear.php.net/package/Mail/
*/
/**
* internal PHP-mail() implementation of the PEAR Mail:: interface.
* @package Mail
- * @version $Revision: 294747 $
+ * @version $Revision$
*/
class Mail_mail extends Mail {
@@ -64,7 +66,7 @@
*
* @param array $params Extra arguments for the mail() function.
*/
- function __construct($params = null)
+ public function __construct($params = null)
{
// The other mail implementations accept parameters as arrays.
// In the interest of being consistent, explode an array into
@@ -109,17 +111,15 @@
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
- *
- * @access public
*/
- function send($recipients, $headers, $body)
+ public function send($recipients, $headers, $body)
{
if (defined('CIVICRM_MAIL_LOG')) {
- CRM_Utils_Mail::logger($recipients, $headers, $body);
- // Note: "CIVICRM_MAIL_LOG_AND SEND" (space not underscore) was a typo that existed for some years, so kept here for compatibility, but it should not be used.
- if(!defined('CIVICRM_MAIL_LOG_AND_SEND') && !defined('CIVICRM_MAIL_LOG_AND SEND')) {
- return true;
- }
+ CRM_Utils_Mail::logger($recipients, $headers, $body);
+ // Note: "CIVICRM_MAIL_LOG_AND SEND" (space not underscore) was a typo that existed for some years, so kept here for compatibility, but it should not be used.
+ if (!defined('CIVICRM_MAIL_LOG_AND_SEND') && !defined('CIVICRM_MAIL_LOG_AND SEND')) {
+ return true;
+ }
}
if (!is_array($headers)) {
@@ -154,7 +154,6 @@
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'];
--- ../../../../packages/Mail/mock.php 2018-12-13 13:10:15.284020773 +1100
+++ mock.php 2017-04-12 03:27:29.000000000 +1000
@@ -2,31 +2,33 @@
/**
* Mock implementation
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE:
*
- * Copyright (c) 2010 Chuck Hagenbuch
+ * Copyright (c) 2010-2017, Chuck Hagenbuch
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
- * o Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * o Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * o The names of the authors may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
@@ -37,9 +39,9 @@
* @category Mail
* @package Mail
* @author Chuck Hagenbuch <chuck@horde.org>
- * @copyright 2010 Chuck Hagenbuch
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: mock.php 294747 2010-02-08 08:18:33Z clockwerx $
+ * @copyright 2010-2017 Chuck Hagenbuch
+ * @license http://opensource.org/licenses/BSD-3-Clause New BSD License
+ * @version CVS: $Id$
* @link http://pear.php.net/package/Mail/
*/
@@ -47,7 +49,7 @@
* Mock implementation of the PEAR Mail:: interface for testing.
* @access public
* @package Mail
- * @version $Revision: 294747 $
+ * @version $Revision$
*/
class Mail_mock extends Mail {
@@ -55,23 +57,22 @@
* Array of messages that have been sent with the mock.
*
* @var array
- * @access public
*/
- var $sentMessages = array();
+ public $sentMessages = array();
/**
* Callback before sending mail.
*
* @var callback
*/
- var $_preSendCallback;
+ protected $_preSendCallback;
/**
* Callback after sending mai.
*
* @var callback
*/
- var $_postSendCallback;
+ protected $_postSendCallback;
/**
* Constructor.
@@ -82,9 +83,8 @@
* postSendCallback Called after an email would have been sent.
*
* @param array Hash containing any parameters.
- * @access public
*/
- function __construct($params)
+ public function __construct($params)
{
if (isset($params['preSendCallback']) &&
is_callable($params['preSendCallback'])) {
@@ -120,9 +120,8 @@
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
- * @access public
*/
- function send($recipients, $headers, $body)
+ public function send($recipients, $headers, $body)
{
if ($this->_preSendCallback) {
call_user_func_array($this->_preSendCallback,
--- ../../../../packages/Mail/null.php 2018-12-13 13:10:15.308020985 +1100
+++ null.php 2017-04-12 03:27:29.000000000 +1000
@@ -2,31 +2,33 @@
/**
* Null implementation of the PEAR Mail interface
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE:
*
- * Copyright (c) 2010 Phil Kernick
+ * Copyright (c) 2010-2017, Phil Kernick
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
- * o Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * o Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * o The names of the authors may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
@@ -37,9 +39,9 @@
* @category Mail
* @package Mail
* @author Phil Kernick <philk@rotfl.com.au>
- * @copyright 2010 Phil Kernick
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: null.php 294747 2010-02-08 08:18:33Z clockwerx $
+ * @copyright 2010-2017 Phil Kernick
+ * @license http://opensource.org/licenses/BSD-3-Clause New BSD License
+ * @version CVS: $Id$
* @link http://pear.php.net/package/Mail/
*/
@@ -47,7 +49,7 @@
* Null implementation of the PEAR Mail:: interface.
* @access public
* @package Mail
- * @version $Revision: 294747 $
+ * @version $Revision$
*/
class Mail_null extends Mail {
@@ -74,9 +76,8 @@
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
- * @access public
*/
- function send($recipients, $headers, $body)
+ public function send($recipients, $headers, $body)
{
return true;
}
--- ../../../../packages/Mail/RFC822.php 2018-12-13 13:10:15.312021020 +1100
+++ RFC822.php 2017-04-12 03:27:29.000000000 +1000
@@ -2,31 +2,33 @@
/**
* RFC 822 Email address list validation Utility
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE:
*
- * Copyright (c) 2001-2010, Richard Heyes
+ * Copyright (c) 2001-2017, Chuck Hagenbuch & Richard Heyes
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
- * o Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * o Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * o The names of the authors may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
@@ -38,9 +40,9 @@
* @package Mail
* @author Richard Heyes <richard@phpguru.org>
* @author Chuck Hagenbuch <chuck@horde.org
- * @copyright 2001-2010 Richard Heyes
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: RFC822.php 294749 2010-02-08 08:22:25Z clockwerx $
+ * @copyright 2001-2017 Richard Heyes
+ * @license http://opensource.org/licenses/BSD-3-Clause New BSD License
+ * @version CVS: $Id$
* @link http://pear.php.net/package/Mail/
*/
@@ -63,7 +65,7 @@
*
* @author Richard Heyes <richard@phpguru.org>
* @author Chuck Hagenbuch <chuck@horde.org>
- * @version $Revision: 294749 $
+ * @version $Revision$
* @license BSD
* @package Mail
*/
@@ -141,7 +143,6 @@
* Sets up the object. The address must either be set here or when
* calling parseAddressList(). One or the other.
*
- * @access public
* @param string $address The address(es) to validate.
* @param string $default_domain Default domain/host etc. If not supplied, will be set to localhost.
* @param boolean $nest_groups Whether to return the structure with groups nested for easier viewing.
@@ -149,7 +150,7 @@
*
* @return object Mail_RFC822 A new Mail_RFC822 object.
*/
- function __construct($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
+ public function __construct($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
{
if (isset($address)) $this->address = $address;
if (isset($default_domain)) $this->default_domain = $default_domain;
@@ -162,7 +163,6 @@
* 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.
@@ -170,7 +170,7 @@
*
* @return array A structured array of addresses.
*/
- function parseAddressList($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
+ public 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);
@@ -222,11 +222,10 @@
/**
* Splits an address into separate addresses.
*
- * @access private
* @param string $address The addresses to split.
* @return boolean Success or failure.
*/
- function _splitAddresses($address)
+ protected function _splitAddresses($address)
{
if (!empty($this->limit) && count($this->addresses) == $this->limit) {
return '';
@@ -298,11 +297,10 @@
/**
* Checks for a group at the start of the string.
*
- * @access private
* @param string $address The address to check.
* @return boolean Whether or not there is a group at the start of the string.
*/
- function _isGroup($address)
+ protected function _isGroup($address)
{
// First comma not in quotes, angles or escaped:
$parts = explode(',', $address);
@@ -322,12 +320,11 @@
/**
* A common function that will check an exploded string.
*
- * @access private
* @param array $parts The exloded string.
* @param string $char The char that was exploded on.
* @return mixed False if the string contains unclosed quotes/brackets, or the string on success.
*/
- function _splitCheck($parts, $char)
+ protected function _splitCheck($parts, $char)
{
$string = $parts[0];
@@ -355,12 +352,11 @@
/**
* Checks if a string has unclosed quotes or not.
*
- * @access private
* @param string $string The string to check.
* @return boolean True if there are unclosed quotes inside the string,
* false otherwise.
*/
- function _hasUnclosedQuotes($string)
+ protected function _hasUnclosedQuotes($string)
{
$string = trim($string);
$iMax = strlen($string);
@@ -392,12 +388,11 @@
* Checks if a string has an unclosed brackets or not. IMPORTANT:
* This function handles both angle brackets and square brackets;
*
- * @access private
* @param string $string The string to check.
* @param string $chars The characters to check for.
* @return boolean True if there are unclosed brackets inside the string, false otherwise.
*/
- function _hasUnclosedBrackets($string, $chars)
+ protected function _hasUnclosedBrackets($string, $chars)
{
$num_angle_start = substr_count($string, $chars[0]);
$num_angle_end = substr_count($string, $chars[1]);
@@ -416,13 +411,12 @@
/**
* Sub function that is used only by hasUnclosedBrackets().
*
- * @access private
* @param string $string The string to check.
* @param integer &$num The number of occurences.
* @param string $char The character to count.
* @return integer The number of occurences of $char in $string, adjusted for backslashes.
*/
- function _hasUnclosedBracketsSub($string, &$num, $char)
+ protected function _hasUnclosedBracketsSub($string, &$num, $char)
{
$parts = explode($char, $string);
for ($i = 0; $i < count($parts); $i++){
@@ -438,11 +432,10 @@
/**
* Function to begin checking the address.
*
- * @access private
* @param string $address The address to validate.
* @return mixed False on failure, or a structured array of address information on success.
*/
- function _validateAddress($address)
+ protected function _validateAddress($address)
{
$is_group = false;
$addresses = array();
@@ -483,14 +476,6 @@
$addresses[] = $address['address'];
}
- // Check that $addresses is set, if address like this:
- // Groupname:;
- // Then errors were appearing.
- if (!count($addresses)){
- $this->error = 'Empty group.';
- return false;
- }
-
// Trim the whitespace from all of the address strings.
array_map('trim', $addresses);
@@ -531,11 +516,10 @@
/**
* Function to validate a phrase.
*
- * @access private
* @param string $phrase The phrase to check.
* @return boolean Success or failure.
*/
- function _validatePhrase($phrase)
+ protected function _validatePhrase($phrase)
{
// Splits on one or more Tab or space.
$parts = preg_split('/[ \\x09]+/', $phrase, -1, PREG_SPLIT_NO_EMPTY);
@@ -572,11 +556,10 @@
* can split a list of addresses up before encoding personal names
* (umlauts, etc.), for example.
*
- * @access private
* @param string $atom The string to check.
* @return boolean Success or failure.
*/
- function _validateAtom($atom)
+ protected function _validateAtom($atom)
{
if (!$this->validate) {
// Validation has been turned off; assume the atom is okay.
@@ -605,11 +588,10 @@
* Function to validate quoted string, which is:
* quoted-string = <"> *(qtext/quoted-pair) <">
*
- * @access private
* @param string $qstring The string to check
* @return boolean Success or failure.
*/
- function _validateQuotedString($qstring)
+ protected function _validateQuotedString($qstring)
{
// Leading and trailing "
$qstring = substr($qstring, 1, -1);
@@ -623,11 +605,10 @@
* mailbox = addr-spec ; simple address
* / phrase route-addr ; name and route-addr
*
- * @access public
* @param string &$mailbox The string to check.
* @return boolean Success or failure.
*/
- function validateMailbox(&$mailbox)
+ public function validateMailbox(&$mailbox)
{
// A couple of defaults.
$phrase = '';
@@ -712,11 +693,10 @@
* Angle brackets have already been removed at the point of
* getting to this function.
*
- * @access private
* @param string $route_addr The string to check.
* @return mixed False on failure, or an array containing validated address/route information on success.
*/
- function _validateRouteAddr($route_addr)
+ protected function _validateRouteAddr($route_addr)
{
// Check for colon.
if (strpos($route_addr, ':') !== false) {
@@ -762,11 +742,10 @@
* Function to validate a route, which is:
* route = 1#("@" domain) ":"
*
- * @access private
* @param string $route The string to check.
* @return mixed False on failure, or the validated $route on success.
*/
- function _validateRoute($route)
+ protected function _validateRoute($route)
{
// Split on comma.
$domains = explode(',', trim($route));
@@ -785,11 +764,10 @@
*
* domain = sub-domain *("." sub-domain)
*
- * @access private
* @param string $domain The string to check.
* @return mixed False on failure, or the validated domain on success.
*/
- function _validateDomain($domain)
+ protected function _validateDomain($domain)
{
// Note the different use of $subdomains and $sub_domains
$subdomains = explode('.', $domain);
@@ -813,11 +791,10 @@
* Function to validate a subdomain:
* subdomain = domain-ref / domain-literal
*
- * @access private
* @param string $subdomain The string to check.
* @return boolean Success or failure.
*/
- function _validateSubdomain($subdomain)
+ protected function _validateSubdomain($subdomain)
{
if (preg_match('|^\[(.*)]$|', $subdomain, $arr)){
if (!$this->_validateDliteral($arr[1])) return false;
@@ -833,13 +810,12 @@
* Function to validate a domain literal:
* domain-literal = "[" *(dtext / quoted-pair) "]"
*
- * @access private
* @param string $dliteral The string to check.
* @return boolean Success or failure.
*/
- function _validateDliteral($dliteral)
+ protected function _validateDliteral($dliteral)
{
- return !preg_match('/(.)[][\x0D\\\\]/', $dliteral, $matches) && $matches[1] != '\\';
+ return !preg_match('/(.)[][\x0D\\\\]/', $dliteral, $matches) && ((! isset($matches[1])) || $matches[1] != '\\');
}
/**
@@ -847,11 +823,10 @@
*
* addr-spec = local-part "@" domain
*
- * @access private
* @param string $addr_spec The string to check.
* @return mixed False on failure, or the validated addr-spec on success.
*/
- function _validateAddrSpec($addr_spec)
+ protected function _validateAddrSpec($addr_spec)
{
$addr_spec = trim($addr_spec);
@@ -878,17 +853,16 @@
* Function to validate the local part of an address:
* local-part = word *("." word)
*
- * @access private
* @param string $local_part
* @return mixed False on failure, or the validated local part on success.
*/
- function _validateLocalPart($local_part)
+ protected function _validateLocalPart($local_part)
{
$parts = explode('.', $local_part);
$words = array();
// Split the local_part into words.
- while (count($parts) > 0){
+ while (count($parts) > 0) {
$words[] = $this->_splitCheck($parts, '.');
for ($i = 0; $i < $this->index + 1; $i++) {
array_shift($parts);
@@ -897,6 +871,10 @@
// Validate each word.
foreach ($words as $word) {
+ // word cannot be empty (#17317)
+ if ($word === '') {
+ return false;
+ }
// If this word contains an unquoted space, it is invalid. (6.2.4)
if (strpos($word, ' ') && $word[0] !== '"')
{
@@ -920,7 +898,7 @@
* @param string $data Addresses to count
* @return int Approximate count
*/
- function approximateCount($data)
+ public function approximateCount($data)
{
return count(preg_split('/(?<!\\\\),/', $data));
}
@@ -938,7 +916,7 @@
* @return mixed False if it fails, an indexed array
* username/domain if it matches
*/
- function isValidInetAddress($data, $strict = false)
+ public function isValidInetAddress($data, $strict = false)
{
$regex = $strict ? '/^([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})$/i' : '/^([*+!.&#$|\'\\%\/0-9a-z^_`{}=?~:-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})$/i';
if (preg_match($regex, trim($data), $matches)) {
--- ../../../../packages/Mail/sendmail.php 2018-12-13 13:10:15.296020878 +1100
+++ sendmail.php 2018-12-30 10:27:31.584583779 +1100
@@ -1,26 +1,56 @@
<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2003 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 2.02 of the PHP license, |
-// | that is bundled with this package in the file LICENSE, and is |
-// | available at through the world-wide-web at |
-// | http://www.php.net/license/2_02.txt. |
-// | If you did not receive a copy of the PHP license and are unable to |
-// | obtain it through the world-wide-web, please send a note to |
-// | license@php.net so we can mail you a copy immediately. |
-// +----------------------------------------------------------------------+
-// | Author: Chuck Hagenbuch <chuck@horde.org> |
-// +----------------------------------------------------------------------+
+/**
+ * Sendmail implementation of the PEAR Mail interface.
+ *
+ * PHP version 5
+ *
+ * LICENSE:
+ *
+ * Copyright (c) 2010-2017, Chuck Hagenbuch & Jon Parise
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Mail
+ * @package Mail
+ * @author Jon Parise <jon@php.net>
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @copyright 2010-2017 Chuck Hagenbuch
+ * @license http://opensource.org/licenses/BSD-3-Clause New BSD License
+ * @version CVS: $Id$
+ * @link http://pear.php.net/package/Mail/
+ */
/**
* Sendmail implementation of the PEAR Mail:: interface.
* @access public
* @package Mail
- * @version $Revision: 294744 $
+ * @version $Revision$
*/
class Mail_sendmail extends Mail {
@@ -54,9 +84,8 @@
*
* @param array $params Hash containing any parameters different from the
* defaults.
- * @access public
*/
- function __construct($params)
+ public function __construct($params)
{
if (isset($params['sendmail_path'])) {
$this->sendmail_path = $params['sendmail_path'];
@@ -100,16 +129,15 @@
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
- * @access public
*/
- function send($recipients, $headers, $body)
+ public function send($recipients, $headers, $body)
{
if (defined('CIVICRM_MAIL_LOG')) {
- CRM_Utils_Mail::logger($recipients, $headers, $body);
- // Note: "CIVICRM_MAIL_LOG_AND SEND" (space not underscore) was a typo that existed for some years, so kept here for compatibility, but it should not be used.
- if(!defined('CIVICRM_MAIL_LOG_AND_SEND') && !defined('CIVICRM_MAIL_LOG_AND SEND')) {
- return true;
- }
+ CRM_Utils_Mail::logger($recipients, $headers, $body);
+ // Note: "CIVICRM_MAIL_LOG_AND SEND" (space not underscore) was a typo that existed for some years, so kept here for compatibility, but it should not be used.
+ if (!defined('CIVICRM_MAIL_LOG_AND_SEND') && !defined('CIVICRM_MAIL_LOG_AND SEND')) {
+ return true;
+ }
}
if (!is_array($headers)) {
--- ../../../../packages/Mail/smtpmx.php 2018-12-13 13:10:15.292020843 +1100
+++ smtpmx.php 2017-04-12 03:27:29.000000000 +1000
@@ -1,4 +1,4 @@
-<?PHP
+<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
@@ -6,31 +6,33 @@
*
* SMTP MX implementation of the PEAR Mail interface. Requires the Net_SMTP class.
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE:
*
- * Copyright (c) 2010, gERD Schaufelberger
+ * Copyright (c) 2010-2017 gERD Schaufelberger
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
- * o Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * o Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * o The names of the authors may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
@@ -41,9 +43,9 @@
* @category Mail
* @package Mail_smtpmx
* @author gERD Schaufelberger <gerd@php-tools.net>
- * @copyright 2010 gERD Schaufelberger
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: smtpmx.php 294747 2010-02-08 08:18:33Z clockwerx $
+ * @copyright 2010-2017 gERD Schaufelberger
+ * @license http://opensource.org/licenses/BSD-3-Clause New BSD License
+ * @version CVS: $Id$
* @link http://pear.php.net/package/Mail/
*/
@@ -56,7 +58,7 @@
* @access public
* @author gERD Schaufelberger <gerd@php-tools.net>
* @package Mail
- * @version $Revision: 294747 $
+ * @version $Revision$
*/
class Mail_smtpmx extends Mail {
@@ -243,12 +245,12 @@
* @access public
* @param array Hash containing any parameters different from the defaults
* @see __construct()
- *
+ */
function Mail_smtpmx($params)
{
$this->__construct($params);
register_shutdown_function(array(&$this, '__destruct'));
- }*/
+ }
/**
* Destructor implementation to ensure that we disconnect from any
@@ -386,7 +388,7 @@
}
// Send data
- $res = $this->_smtp->data("$textHeaders\r\n$body");
+ $res = $this->_smtp->data($body, $textHeaders);
if (is_a($res, 'PEAR_Error')) {
$info = array('rcpt' => $rcpt);
return $this->_raiseError('failed_send_data', $info);
--- ../../../../packages/Mail/smtp.php 2018-12-13 13:10:15.276020702 +1100
+++ smtp.php 2018-12-30 10:27:31.584583779 +1100
@@ -2,31 +2,33 @@
/**
* SMTP implementation of the PEAR Mail interface. Requires the Net_SMTP class.
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE:
*
- * Copyright (c) 2010, Chuck Hagenbuch
+ * Copyright (c) 2010-2017, Chuck Hagenbuch & Jon Parise
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
- * o Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * o Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * o The names of the authors may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
@@ -38,9 +40,9 @@
* @package HTTP_Request
* @author Jon Parise <jon@php.net>
* @author Chuck Hagenbuch <chuck@horde.org>
- * @copyright 2010 Chuck Hagenbuch
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: smtp.php 294747 2010-02-08 08:18:33Z clockwerx $
+ * @copyright 2010-2017 Chuck Hagenbuch
+ * @license http://opensource.org/licenses/BSD-3-Clause New BSD License
+ * @version CVS: $Id$
* @link http://pear.php.net/package/Mail/
*/
@@ -69,7 +71,7 @@
* SMTP implementation of the PEAR Mail interface. Requires the Net_SMTP class.
* @access public
* @package Mail
- * @version $Revision: 294747 $
+ * @version $Revision$
*/
class Mail_smtp extends Mail {
@@ -84,18 +86,21 @@
/**
* The list of service extension parameters to pass to the Net_SMTP
* mailFrom() command.
+ *
* @var array
*/
var $_extparams = array();
/**
* The SMTP host to connect to.
+ *
* @var string
*/
var $host = 'localhost';
/**
* The port the SMTP server is on.
+ *
* @var integer
*/
var $port = 25;
@@ -115,12 +120,14 @@
/**
* The username to use if the SMTP server requires authentication.
+ *
* @var string
*/
var $username = '';
/**
* The password to use if the SMTP server requires authentication.
+ *
* @var string
*/
var $password = '';
@@ -159,11 +166,19 @@
* Use SMTP command pipelining (specified in RFC 2920) if the SMTP server
* supports it. This speeds up delivery over high-latency connections. By
* default, use the default value supplied by Net_SMTP.
- * @var bool
+ *
+ * @var boolean
*/
var $pipelining;
/**
+ * The list of socket options
+ *
+ * @var array
+ */
+ var $socket_options = array();
+
+ /**
* Constructor.
*
* Instantiates a new Mail_smtp:: object based on the parameters
@@ -186,9 +201,8 @@
*
* @param array Hash containing any parameters different from the
* defaults.
- * @access public
*/
- function __construct($params)
+ public function __construct($params)
{
if (isset($params['host'])) $this->host = $params['host'];
if (isset($params['port'])) $this->port = $params['port'];
@@ -200,20 +214,18 @@
if (isset($params['debug'])) $this->debug = (bool)$params['debug'];
if (isset($params['persist'])) $this->persist = (bool)$params['persist'];
if (isset($params['pipelining'])) $this->pipelining = (bool)$params['pipelining'];
-
+ if (isset($params['socket_options'])) $this->socket_options = $params['socket_options'];
// Deprecated options
if (isset($params['verp'])) {
$this->addServiceExtensionParameter('XVERP', is_bool($params['verp']) ? null : $params['verp']);
}
-
- register_shutdown_function(array(&$this, '_Mail_smtp'));
}
/**
* Destructor implementation to ensure that we disconnect from any
* potentially-alive persistent SMTP connections.
*/
- function _Mail_smtp()
+ public function __destruct()
{
$this->disconnect();
}
@@ -240,20 +252,31 @@
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
- * @access public
*/
- function send($recipients, $headers, $body)
+ public function send($recipients, $headers, $body)
{
if (defined('CIVICRM_MAIL_LOG')) {
- CRM_Utils_Mail::logger($recipients, $headers, $body);
- // Note: "CIVICRM_MAIL_LOG_AND SEND" (space not underscore) was a typo that existed for some years, so kept here for compatibility, but it should not be used.
- if(!defined('CIVICRM_MAIL_LOG_AND_SEND') && !defined('CIVICRM_MAIL_LOG_AND SEND')) {
- return true;
- }
+ CRM_Utils_Mail::logger($recipients, $headers, $body);
+ // Note: "CIVICRM_MAIL_LOG_AND SEND" (space not underscore) was a typo that existed for some years, so kept here for compatibility, but it should not be used.
+ if (!defined('CIVICRM_MAIL_LOG_AND_SEND') && !defined('CIVICRM_MAIL_LOG_AND SEND')) {
+ return true;
+ }
}
+ $result = $this->send_or_fail($recipients, $headers, $body);
+
+ /* If persistent connections are disabled, destroy our SMTP object. */
+ if ($this->persist === false) {
+ $this->disconnect();
+ }
+
+ return $result;
+ }
+
+ protected function send_or_fail($recipients, $headers, $body)
+ {
/* If we don't already have an SMTP object, create one. */
- $result = &$this->getSMTPObject();
+ $result = $this->getSMTPObject();
if (PEAR::isError($result)) {
return $result;
}
@@ -312,16 +335,16 @@
}
/* 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();
+ $res = $this->_smtp->data($body, $textHeaders);
+ 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 (preg_match("/ 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);
@@ -329,11 +352,6 @@
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;
}
@@ -345,9 +363,8 @@
* failure.
*
* @since 1.2.0
- * @access public
*/
- function &getSMTPObject()
+ public function getSMTPObject()
{
if (is_object($this->_smtp) !== false) {
return $this->_smtp;
@@ -356,7 +373,10 @@
include_once 'Net/SMTP.php';
$this->_smtp = new Net_SMTP($this->host,
$this->port,
- $this->localhost);
+ $this->localhost,
+ $this->pipelining,
+ 0,
+ $this->socket_options);
/* If we still don't have an SMTP object at this point, fail. */
if (is_object($this->_smtp) === false) {
@@ -401,9 +421,8 @@
* @param string Any value the keyword needs.
*
* @since 1.2.0
- * @access public
*/
- function addServiceExtensionParameter($keyword, $value = null)
+ public function addServiceExtensionParameter($keyword, $value = null)
{
$this->_extparams[$keyword] = $value;
}
@@ -414,9 +433,8 @@
* @return boolean True if the SMTP connection no longer exists.
*
* @since 1.1.9
- * @access public
*/
- function disconnect()
+ public function disconnect()
{
/* If we have an SMTP object, disconnect and destroy it. */
if (is_object($this->_smtp) && $this->_smtp->disconnect()) {
@@ -436,9 +454,8 @@
* @return string A string describing the current SMTP error.
*
* @since 1.1.7
- * @access private
*/
- function _error($text, &$error)
+ protected function _error($text, $error)
{
/* Split the SMTP response into a code and a response string. */
list($code, $response) = $this->_smtp->getResponse();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment