1.3.0 (stable) was released on 2016-01-31
Source: https://pear.php.net/package/Mail
- * PEAR's Mail:: interface.
+ * PEAR's Mail:: interface.
* @author Chuck Hagenbuch <chuck@horde.org>
* @copyright 1997-2010 Chuck Hagenbuch
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @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 $
* @link http://pear.php.net/package/Mail/
*/
* @link http://pear.php.net/package/Mail/
*/
* mailers under the PEAR hierarchy, and provides supporting functions
* useful in multiple mailer backends.
*
* mailers under the PEAR hierarchy, and provides supporting functions
* useful in multiple mailer backends.
*
- * @access public
- * @version $Revision: 294747 $
* @package Mail
*/
class Mail
* @package Mail
*/
class Mail
* Line terminator used for separating header lines.
* @var string
*/
* Line terminator used for separating header lines.
* @var string
*/
/**
* Provides an interface for generating Mail:: objects of various
/**
* Provides an interface for generating Mail:: objects of various
*
* @param string $driver The kind of Mail:: object to instantiate.
* @param array $params The parameters to pass to the Mail:: object.
*
* @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
* @return object Mail a instance of the driver class or if fails a PEAR Error
- function &factory($driver, $params = array())
+ public static function factory($driver, $params = array())
{
$driver = strtolower($driver);
@include_once 'Mail/' . $driver . '.php';
{
$driver = strtolower($driver);
@include_once 'Mail/' . $driver . '.php';
* containing a descriptive error message on
* failure.
*
* containing a descriptive error message on
* failure.
*
* @deprecated use Mail_mail::send instead
*/
* @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');
{
if (!is_array($headers)) {
return PEAR::raiseError('$headers must be an array');
* filter is to prevent mail injection attacks.
*
* @param array $headers The associative array of headers to sanitize.
* filter is to prevent mail injection attacks.
*
* @param array $headers The associative array of headers to sanitize.
- function _sanitizeHeaders(&$headers)
+ protected function _sanitizeHeaders(&$headers)
{
foreach ($headers as $key => $value) {
$headers[$key] =
{
foreach ($headers as $key => $value) {
$headers[$key] =
* otherwise returns an array containing two
* elements: Any From: address found in the headers,
* and the plain text version of the headers.
* otherwise returns an array containing two
* elements: Any From: address found in the headers,
* and the plain text version of the headers.
- function prepareHeaders($headers)
+ protected function prepareHeaders($headers)
{
$lines = array();
$from = null;
{
$lines = array();
$from = null;
*
* @return mixed An array of forward paths (bare addresses) or a PEAR_Error
* object if the address list could not be parsed.
*
* @return mixed An array of forward paths (bare addresses) or a PEAR_Error
* object if the address list could not be parsed.
- function parseRecipients($recipients)
+ protected function parseRecipients($recipients)
{
include_once 'Mail/RFC822.php';
{
include_once 'Mail/RFC822.php';
// Parse recipients, leaving out all personal info. This is
// for smtp recipients, etc. All relevant personal information
// should already be in the headers.
// 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);
+ $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')) {
// If parseAddressList() returned a PEAR_Error object, just return it.
if (is_a($addresses, 'PEAR_Error')) {
/**
* RFC 822 Email address list validation Utility
*
/**
* RFC 822 Email address list validation Utility
*
* @author Chuck Hagenbuch <chuck@horde.org
* @copyright 2001-2010 Richard Heyes
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @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 $
* @link http://pear.php.net/package/Mail/
*/
* @link http://pear.php.net/package/Mail/
*/
*
* @author Richard Heyes <richard@phpguru.org>
* @author Chuck Hagenbuch <chuck@horde.org>
*
* @author Richard Heyes <richard@phpguru.org>
* @author Chuck Hagenbuch <chuck@horde.org>
- * @version $Revision: 294749 $
* @license BSD
* @package Mail
*/
* @license BSD
* @package Mail
*/
* Sets up the object. The address must either be set here or when
* calling parseAddressList(). One or the other.
*
* Sets up the object. The address must either be set here or when
* calling parseAddressList(). One or the other.
*
* @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.
* @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.
*
* @return object Mail_RFC822 A new Mail_RFC822 object.
*/
*
* @return object Mail_RFC822 A new Mail_RFC822 object.
*/
- function Mail_RFC822($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;
{
if (isset($address)) $this->address = $address;
if (isset($default_domain)) $this->default_domain = $default_domain;
* Starts the whole process. The address must either be set here
* or when creating the object. One or the other.
*
* Starts the whole process. The address must either be set here
* or when creating the object. One or the other.
*
* @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 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.
*
* @return array A structured array of addresses.
*/
*
* @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);
{
if (!isset($this) || !isset($this->mailRFC822)) {
$obj = new Mail_RFC822($address, $default_domain, $nest_groups, $validate, $limit);
/**
* Splits an address into separate addresses.
*
/**
* Splits an address into separate addresses.
*
* @param string $address The addresses to split.
* @return boolean Success or failure.
*/
* @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 '';
{
if (!empty($this->limit) && count($this->addresses) == $this->limit) {
return '';
/**
* Checks for a group at the start of the string.
*
/**
* Checks for a group at the start of the string.
*
* @param string $address The address to check.
* @return boolean Whether or not there is a group at the start of the string.
*/
* @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);
{
// First comma not in quotes, angles or escaped:
$parts = explode(',', $address);
/**
* A common function that will check an exploded string.
*
/**
* A common function that will check an exploded string.
*
* @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.
*/
* @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)
/**
* Checks if a string has unclosed quotes or not.
*
/**
* Checks if a string has unclosed quotes or not.
*
* @param string $string The string to check.
* @return boolean True if there are unclosed quotes inside the string,
* false otherwise.
*/
* @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);
{
$string = trim($string);
$iMax = strlen($string);
* Checks if a string has an unclosed brackets or not. IMPORTANT:
* This function handles both angle brackets and square brackets;
*
* Checks if a string has an unclosed brackets or not. IMPORTANT:
* This function handles both angle brackets and square brackets;
*
* @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.
*/
* @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]);
{
$num_angle_start = substr_count($string, $chars[0]);
$num_angle_end = substr_count($string, $chars[1]);
/**
* Sub function that is used only by hasUnclosedBrackets().
*
/**
* Sub function that is used only by hasUnclosedBrackets().
*
* @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.
*/
* @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++){
{
$parts = explode($char, $string);
for ($i = 0; $i < count($parts); $i++){
/**
* Function to begin checking the address.
*
/**
* Function to begin checking the address.
*
* @param string $address The address to validate.
* @return mixed False on failure, or a structured array of address information on success.
*/
* @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();
{
$is_group = false;
$addresses = array();
$addresses[] = $address['address'];
}
$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);
// Trim the whitespace from all of the address strings.
array_map('trim', $addresses);
/**
* Function to validate a phrase.
*
/**
* Function to validate a phrase.
*
* @param string $phrase The phrase to check.
* @return boolean Success or failure.
*/
* @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);
{
// Splits on one or more Tab or space.
$parts = preg_split('/[ \\x09]+/', $phrase, -1, PREG_SPLIT_NO_EMPTY);
* can split a list of addresses up before encoding personal names
* (umlauts, etc.), for example.
*
* can split a list of addresses up before encoding personal names
* (umlauts, etc.), for example.
*
* @param string $atom The string to check.
* @return boolean Success or failure.
*/
* @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.
{
if (!$this->validate) {
// Validation has been turned off; assume the atom is okay.
* Function to validate quoted string, which is:
* quoted-string = <"> *(qtext/quoted-pair) <">
*
* Function to validate quoted string, which is:
* quoted-string = <"> *(qtext/quoted-pair) <">
*
* @param string $qstring The string to check
* @return boolean Success or failure.
*/
* @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);
{
// Leading and trailing "
$qstring = substr($qstring, 1, -1);
* mailbox = addr-spec ; simple address
* / phrase route-addr ; name and route-addr
*
* mailbox = addr-spec ; simple address
* / phrase route-addr ; name and route-addr
*
* @param string &$mailbox The string to check.
* @return boolean Success or failure.
*/
* @param string &$mailbox The string to check.
* @return boolean Success or failure.
*/
- function validateMailbox(&$mailbox)
+ public function validateMailbox(&$mailbox)
{
// A couple of defaults.
$phrase = '';
{
// A couple of defaults.
$phrase = '';
* Angle brackets have already been removed at the point of
* getting to this function.
*
* Angle brackets have already been removed at the point of
* getting to this function.
*
* @param string $route_addr The string to check.
* @return mixed False on failure, or an array containing validated address/route information on success.
*/
* @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) {
{
// Check for colon.
if (strpos($route_addr, ':') !== false) {
* Function to validate a route, which is:
* route = 1#("@" domain) ":"
*
* Function to validate a route, which is:
* route = 1#("@" domain) ":"
*
* @param string $route The string to check.
* @return mixed False on failure, or the validated $route on success.
*/
* @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));
{
// Split on comma.
$domains = explode(',', trim($route));
*
* domain = sub-domain *("." sub-domain)
*
*
* domain = sub-domain *("." sub-domain)
*
* @param string $domain The string to check.
* @return mixed False on failure, or the validated domain on success.
*/
* @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);
{
// Note the different use of $subdomains and $sub_domains
$subdomains = explode('.', $domain);
* Function to validate a subdomain:
* subdomain = domain-ref / domain-literal
*
* Function to validate a subdomain:
* subdomain = domain-ref / domain-literal
*
* @param string $subdomain The string to check.
* @return boolean Success or failure.
*/
* @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;
{
if (preg_match('|^\[(.*)]$|', $subdomain, $arr)){
if (!$this->_validateDliteral($arr[1])) return false;
* Function to validate a domain literal:
* domain-literal = "[" *(dtext / quoted-pair) "]"
*
* Function to validate a domain literal:
* domain-literal = "[" *(dtext / quoted-pair) "]"
*
* @param string $dliteral The string to check.
* @return boolean Success or failure.
*/
* @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) && $matches[1] != '\\';
}
*
* addr-spec = local-part "@" domain
*
*
* addr-spec = local-part "@" domain
*
* @param string $addr_spec The string to check.
* @return mixed False on failure, or the validated addr-spec on success.
*/
* @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);
{
$addr_spec = trim($addr_spec);
* Function to validate the local part of an address:
* local-part = word *("." word)
*
* Function to validate the local part of an address:
* local-part = word *("." word)
*
* @param string $local_part
* @return mixed False on failure, or the validated local part on success.
*/
* @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.
{
$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);
$words[] = $this->_splitCheck($parts, '.');
for ($i = 0; $i < $this->index + 1; $i++) {
array_shift($parts);
// Validate each word.
foreach ($words as $word) {
// 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] !== '"')
{
// If this word contains an unquoted space, it is invalid. (6.2.4)
if (strpos($word, ' ') && $word[0] !== '"')
{
* @param string $data Addresses to count
* @return int Approximate count
*/
* @param string $data Addresses to count
* @return int Approximate count
*/
- function approximateCount($data)
+ public function approximateCount($data)
{
return count(preg_split('/(?<!\\\\),/', $data));
}
{
return count(preg_split('/(?<!\\\\),/', $data));
}
* @return mixed False if it fails, an indexed array
* username/domain if it matches
*/
* @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)) {
{
$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)) {
/**
* internal PHP-mail() implementation of the PEAR Mail:: interface.
*
/**
* internal PHP-mail() implementation of the PEAR Mail:: interface.
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @copyright 2010 Chuck Hagenbuch
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @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 $
* @link http://pear.php.net/package/Mail/
*/
/**
* internal PHP-mail() implementation of the PEAR Mail:: interface.
* @package Mail
* @link http://pear.php.net/package/Mail/
*/
/**
* internal PHP-mail() implementation of the PEAR Mail:: interface.
* @package Mail
- * @version $Revision: 294747 $
*/
class Mail_mail extends Mail {
*/
class Mail_mail extends Mail {
*
* @param array $params Extra arguments for the mail() function.
*/
*
* @param array $params Extra arguments for the mail() function.
*/
- function Mail_mail($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
{
// The other mail implementations accept parameters as arrays.
// In the interest of being consistent, explode an array into
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
- function send($recipients, $headers, $body)
+ public function send($recipients, $headers, $body)
{
if (!is_array($headers)) {
return PEAR::raiseError('$headers must be an array');
{
if (!is_array($headers)) {
return PEAR::raiseError('$headers must be an array');
/**
* Mock implementation
*
/**
* Mock implementation
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @copyright 2010 Chuck Hagenbuch
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @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 $
* @link http://pear.php.net/package/Mail/
*/
* @link http://pear.php.net/package/Mail/
*/
* Mock implementation of the PEAR Mail:: interface for testing.
* @access public
* @package Mail
* Mock implementation of the PEAR Mail:: interface for testing.
* @access public
* @package Mail
- * @version $Revision: 294747 $
*/
class Mail_mock extends Mail {
*/
class Mail_mock extends Mail {
* Array of messages that have been sent with the mock.
*
* @var array
* Array of messages that have been sent with the mock.
*
* @var array
- var $sentMessages = array();
+ public $sentMessages = array();
/**
* Callback before sending mail.
*
* @var callback
*/
/**
* Callback before sending mail.
*
* @var callback
*/
+ protected $_preSendCallback;
/**
* Callback after sending mai.
*
* @var callback
*/
/**
* Callback after sending mai.
*
* @var callback
*/
- var $_postSendCallback;
+ protected $_postSendCallback;
* postSendCallback Called after an email would have been sent.
*
* @param array Hash containing any parameters.
* postSendCallback Called after an email would have been sent.
*
* @param array Hash containing any parameters.
- function Mail_mock($params)
+ public function __construct($params)
{
if (isset($params['preSendCallback']) &&
is_callable($params['preSendCallback'])) {
{
if (isset($params['preSendCallback']) &&
is_callable($params['preSendCallback'])) {
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
- function send($recipients, $headers, $body)
+ public function send($recipients, $headers, $body)
{
if ($this->_preSendCallback) {
call_user_func_array($this->_preSendCallback,
{
if ($this->_preSendCallback) {
call_user_func_array($this->_preSendCallback,
/**
* Null implementation of the PEAR Mail interface
*
/**
* Null implementation of the PEAR Mail interface
*
* @author Phil Kernick <philk@rotfl.com.au>
* @copyright 2010 Phil Kernick
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @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 $
* @link http://pear.php.net/package/Mail/
*/
* @link http://pear.php.net/package/Mail/
*/
* Null implementation of the PEAR Mail:: interface.
* @access public
* @package Mail
* Null implementation of the PEAR Mail:: interface.
* @access public
* @package Mail
- * @version $Revision: 294747 $
*/
class Mail_null extends Mail {
*/
class Mail_null extends Mail {
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
- function send($recipients, $headers, $body)
+ public function send($recipients, $headers, $body)
<?php
//
// +----------------------------------------------------------------------+
<?php
//
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
* Sendmail implementation of the PEAR Mail:: interface.
* @access public
* @package Mail
* Sendmail implementation of the PEAR Mail:: interface.
* @access public
* @package Mail
- * @version $Revision: 294744 $
*/
class Mail_sendmail extends Mail {
*/
class Mail_sendmail extends Mail {
*
* @param array $params Hash containing any parameters different from the
* defaults.
*
* @param array $params Hash containing any parameters different from the
* defaults.
- function Mail_sendmail($params)
+ public function __construct($params)
{
if (isset($params['sendmail_path'])) {
$this->sendmail_path = $params['sendmail_path'];
{
if (isset($params['sendmail_path'])) {
$this->sendmail_path = $params['sendmail_path'];
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
- function send($recipients, $headers, $body)
+ public function send($recipients, $headers, $body)
{
if (!is_array($headers)) {
return PEAR::raiseError('$headers must be an array');
{
if (!is_array($headers)) {
return PEAR::raiseError('$headers must be an array');
/**
* SMTP implementation of the PEAR Mail interface. Requires the Net_SMTP class.
*
/**
* SMTP implementation of the PEAR Mail interface. Requires the Net_SMTP class.
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @copyright 2010 Chuck Hagenbuch
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @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 $
* @link http://pear.php.net/package/Mail/
*/
* @link http://pear.php.net/package/Mail/
*/
* SMTP implementation of the PEAR Mail interface. Requires the Net_SMTP class.
* @access public
* @package Mail
* SMTP implementation of the PEAR Mail interface. Requires the Net_SMTP class.
* @access public
* @package Mail
- * @version $Revision: 294747 $
*/
class Mail_smtp extends Mail {
*/
class Mail_smtp extends Mail {
* @var bool
*/
var $pipelining;
* @var bool
*/
var $pipelining;
+
+ var $socket_options = array();
*
* @param array Hash containing any parameters different from the
* defaults.
*
* @param array Hash containing any parameters different from the
* defaults.
- function Mail_smtp($params)
+ public function __construct($params)
{
if (isset($params['host'])) $this->host = $params['host'];
if (isset($params['port'])) $this->port = $params['port'];
{
if (isset($params['host'])) $this->host = $params['host'];
if (isset($params['port'])) $this->port = $params['port'];
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['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']);
}
// 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.
*/
}
/**
* Destructor implementation to ensure that we disconnect from any
* potentially-alive persistent SMTP connections.
*/
+ public function __destruct()
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
- function send($recipients, $headers, $body)
+ public function send($recipients, $headers, $body)
{
/* If we don't already have an SMTP object, create one. */
{
/* If we don't already have an SMTP object, create one. */
- $result = &$this->getSMTPObject();
+ $result = $this->getSMTPObject();
if (PEAR::isError($result)) {
return $result;
}
if (PEAR::isError($result)) {
return $result;
}
}
/* Send the message's headers and the body as SMTP data. */
}
/* Send the message's headers and the body as SMTP data. */
- $res = $this->_smtp->data($textHeaders . "\r\n\r\n" . $body);
+ $res = $this->_smtp->data($body, $textHeaders);
list(,$args) = $this->_smtp->getResponse();
if (preg_match("/Ok: queued as (.*)/", $args, $queued)) {
list(,$args) = $this->_smtp->getResponse();
if (preg_match("/Ok: queued as (.*)/", $args, $queued)) {
* failure.
*
* @since 1.2.0
* failure.
*
* @since 1.2.0
- function &getSMTPObject()
+ public function getSMTPObject()
{
if (is_object($this->_smtp) !== false) {
return $this->_smtp;
}
include_once 'Net/SMTP.php';
{
if (is_object($this->_smtp) !== false) {
return $this->_smtp;
}
include_once 'Net/SMTP.php';
- $this->_smtp = &new Net_SMTP($this->host,
+ $this->_smtp = new Net_SMTP($this->host,
+ $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) {
/* If we still don't have an SMTP object at this point, fail. */
if (is_object($this->_smtp) === false) {
* @param string Any value the keyword needs.
*
* @since 1.2.0
* @param string Any value the keyword needs.
*
* @since 1.2.0
- function addServiceExtensionParameter($keyword, $value = null)
+ public function addServiceExtensionParameter($keyword, $value = null)
{
$this->_extparams[$keyword] = $value;
}
{
$this->_extparams[$keyword] = $value;
}
* @return boolean True if the SMTP connection no longer exists.
*
* @since 1.1.9
* @return boolean True if the SMTP connection no longer exists.
*
* @since 1.1.9
+ public function disconnect()
{
/* If we have an SMTP object, disconnect and destroy it. */
if (is_object($this->_smtp) && $this->_smtp->disconnect()) {
{
/* If we have an SMTP object, disconnect and destroy it. */
if (is_object($this->_smtp) && $this->_smtp->disconnect()) {
* @return string A string describing the current SMTP error.
*
* @since 1.1.7
* @return string A string describing the current SMTP error.
*
* @since 1.1.7
- 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();
{
/* Split the SMTP response into a code and a response string. */
list($code, $response) = $this->_smtp->getResponse();
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
*
* SMTP MX implementation of the PEAR Mail interface. Requires the Net_SMTP class.
*
*
* SMTP MX implementation of the PEAR Mail interface. Requires the Net_SMTP class.
*
* @author gERD Schaufelberger <gerd@php-tools.net>
* @copyright 2010 gERD Schaufelberger
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @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 $
* @link http://pear.php.net/package/Mail/
*/
* @link http://pear.php.net/package/Mail/
*/
* @access public
* @author gERD Schaufelberger <gerd@php-tools.net>
* @package Mail
* @access public
* @author gERD Schaufelberger <gerd@php-tools.net>
* @package Mail
- * @version $Revision: 294747 $
*/
class Mail_smtpmx extends Mail {
*/
class Mail_smtpmx extends Mail {
- $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);
if (is_a($res, 'PEAR_Error')) {
$info = array('rcpt' => $rcpt);
return $this->_raiseError('failed_send_data', $info);