diff --git a/Mail/smtp.php b/Mail/smtp.php index 8a3b372..7a9fda2 100644 --- a/Mail/smtp.php +++ b/Mail/smtp.php @@ -173,6 +173,13 @@ class Mail_smtp extends Mail { */ var $debug = false; + /** + * Set debug_handler on Net_SMTP + * + * @var callable $debug_handler + */ + var $debug_handler = null; + /** * 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 @@ -224,19 +231,21 @@ class Mail_smtp extends Mail { * * Instantiates a new Mail_smtp:: object based on the parameters * passed in. It looks for the following parameters: - * host The server to connect to. Defaults to localhost. - * port The port to connect to. Defaults to 25. - * auth SMTP authentication. Defaults to none. - * starttls Should STARTTLS connection be used? No default. PEAR/Net_SMTP >= 1.10.0 required. - * username The username to use for SMTP auth. No default. - * password The password to use for SMTP auth. No default. - * localhost The local hostname / domain. Defaults to localhost. - * timeout The SMTP connection timeout. Defaults to none. - * verp Whether to use VERP or not. Defaults to false. - * DEPRECATED as of 1.2.0 (use setMailParams()). - * debug Activate SMTP debug mode? Defaults to false. - * persist Should the SMTP connection persist? - * pipelining Use SMTP command pipelining + * host The server to connect to. Defaults to localhost. + * port The port to connect to. Defaults to 25. + * auth SMTP authentication. Defaults to none. + * starttls Should STARTTLS connection be used? No default. PEAR/Net_SMTP >= 1.10.0 required. + * username The username to use for SMTP auth. No default. + * password The password to use for SMTP auth. No default. + * localhost The local hostname / domain. Defaults to localhost. + * timeout The SMTP connection timeout. Defaults to none. + * verp Whether to use VERP or not. Defaults to false. + * DEPRECATED as of 1.2.0 (use setMailParams()). + * debug Activate SMTP debug mode? Defaults to false. + * debug_handler Set SMTP debug handler function. Defaults to null. + * persist Should the SMTP connection persist? + * pipelining Use SMTP command pipelining + * socket_options Socket stream_context_create() options. * * If a parameter is present in the $params array, it replaces the * default. @@ -255,6 +264,7 @@ public function __construct($params) if (isset($params['localhost'])) $this->localhost = $params['localhost']; if (isset($params['timeout'])) $this->timeout = $params['timeout']; if (isset($params['debug'])) $this->debug = (bool)$params['debug']; + if (isset($params['debug_handler'])) $this->debug_handler = $params['debug_handler']; 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']; @@ -421,7 +431,7 @@ public function getSMTPObject() /* Configure the SMTP connection. */ if ($this->debug) { - $this->_smtp->setDebug(true); + $this->_smtp->setDebug(true, $this->debug_handler); } /* Attempt to connect to the configured SMTP server. */ diff --git a/Mail/smtpmx.php b/Mail/smtpmx.php index 91b7e56..42a34b7 100644 --- a/Mail/smtpmx.php +++ b/Mail/smtpmx.php @@ -125,24 +125,31 @@ class Mail_smtpmx extends Mail { /** * Switch to test mode - don't send emails for real * - * @var boolean $debug + * @var boolean $test */ var $test = false; /** * Turn on Net_SMTP debugging? * - * @var boolean $peardebug + * @var boolean $debug */ var $debug = false; + /** + * Set debug_handler on Net_SMTP + * + * @var string $debug_handler + */ + var $debug_handler = null; + /** * internal error codes * * translate internal error identifier to PEAR-Error codes and human * readable messages. * - * @var boolean $debug + * @var array $errorCode * @todo as I need unique error-codes to identify what exactly went wrond * I did not use intergers as it should be. Instead I added a "namespace" * for each code. This avoids conflicts with error codes from different @@ -196,14 +203,15 @@ class Mail_smtpmx extends Mail { * * Instantiates a new Mail_smtp:: object based on the parameters * passed in. It looks for the following parameters: - * mailname The name of the local mail system (a valid hostname which matches the reverse lookup) - * port smtp-port - the default comes from getservicebyname() and should work fine - * timeout The SMTP connection timeout. Defaults to 30 seconds. - * vrfy Whether to use VRFY or not. Defaults to false. - * verp Whether to use VERP or not. Defaults to false. - * test Activate test mode? Defaults to false. - * debug Activate SMTP and Net_DNS debug mode? Defaults to false. - * netdns whether to use PEAR:Net_DNS or the PHP build in function getmxrr, default is true + * mailname The name of the local mail system (a valid hostname which matches the reverse lookup) + * port smtp-port - the default comes from getservicebyname() and should work fine + * timeout The SMTP connection timeout. Defaults to 30 seconds. + * vrfy Whether to use VRFY or not. Defaults to false. + * verp Whether to use VERP or not. Defaults to false. + * test Activate test mode? Defaults to false. + * debug Activate SMTP and Net_DNS debug mode? Defaults to false. + * debug_handler Set SMTP debug handler function. Defaults to null. + * netdns whether to use PEAR:Net_DNS or the PHP build in function getmxrr, default is true * * If a parameter is present in the $params array, it replaces the * default. @@ -233,9 +241,12 @@ function __construct($params) } if (isset($params['timeout'])) $this->timeout = $params['timeout']; + if (isset($params['vrfy'])) $this->vrfy = (bool)$params['vrfy']; if (isset($params['verp'])) $this->verp = $params['verp']; - if (isset($params['test'])) $this->test = $params['test']; - if (isset($params['peardebug'])) $this->test = $params['peardebug']; + if (isset($params['test'])) $this->test = (bool)$params['test']; + if (isset($params['peardebug'])) $this->debug = (bool)$params['peardebug']; + if (isset($params['debug'])) $this->debug = (bool)$params['debug']; + if (isset($params['debug_handler'])) $this->debug_handler = $params['debug_handler']; if (isset($params['netdns'])) $this->withNetDns = $params['netdns']; } @@ -324,7 +335,7 @@ function send($recipients, $headers, $body) // configure the SMTP connection. if ($this->debug) { - $this->_smtp->setDebug(true); + $this->_smtp->setDebug(true, $this->debug_handler); } // attempt to connect to the configured SMTP server. @@ -464,7 +475,7 @@ function _loadNetDns() $this->resolver = new Net_DNS_Resolver(); if ($this->debug) { - $this->resolver->test = 1; + $this->resolver->debug = 1; } return true;