Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Adding support for passing additional socket options.

Request: 18418
  • Loading branch information...
commit 3c054fc005f98990dd7a8e9e9577379030aec86a 1 parent 2ef7e09
Jon Parise jparise authored

Showing 2 changed files with 14 additions and 2 deletions. Show diff stats Hide diff stats

  1. +13 2 SMTP.php
  2. +1 0  package.xml
15 SMTP.php
@@ -106,6 +106,14 @@ class Net_SMTP
106 106 var $_socket = null;
107 107
108 108 /**
  109 + * Array of socket options that will be passed to Net_Socket::connect().
  110 + * @see stream_context_create()
  111 + * @var array
  112 + * @access private
  113 + */
  114 + var $_socket_options = null;
  115 +
  116 + /**
109 117 * The socket I/O timeout value in seconds.
110 118 * @var int
111 119 * @access private
@@ -156,12 +164,13 @@ class Net_SMTP
156 164 * @param string $localhost The value to give when sending EHLO or HELO.
157 165 * @param boolean $pipeling Use SMTP command pipelining
158 166 * @param integer $timeout Socket I/O timeout in seconds.
  167 + * @param array $socket_options Socket stream_context_create() options.
159 168 *
160 169 * @access public
161 170 * @since 1.0
162 171 */
163 172 function Net_SMTP($host = null, $port = null, $localhost = null,
164   - $pipelining = false, $timeout = 0)
  173 + $pipelining = false, $timeout = 0, $socket_options = null)
165 174 {
166 175 if (isset($host)) {
167 176 $this->host = $host;
@@ -175,6 +184,7 @@ function Net_SMTP($host = null, $port = null, $localhost = null,
175 184 $this->pipelining = $pipelining;
176 185
177 186 $this->_socket = new Net_Socket();
  187 + $this->_socket_options = $socket_options;
178 188 $this->_timeout = $timeout;
179 189
180 190 /* Include the Auth_SASL package. If the package is not
@@ -405,7 +415,8 @@ function connect($timeout = null, $persistent = false)
405 415 {
406 416 $this->_greeting = null;
407 417 $result = $this->_socket->connect($this->host, $this->port,
408   - $persistent, $timeout);
  418 + $persistent, $timeout,
  419 + $this->_socket_options);
409 420 if (PEAR::isError($result)) {
410 421 return PEAR::raiseError('Failed to connect socket: ' .
411 422 $result->getMessage());
1  package.xml
@@ -31,6 +31,7 @@
31 31 </stability>
32 32 <license uri="http://www.php.net/license/3_01.txt">PHP License</license>
33 33 <notes>- Avoid requesting immediate socket timeouts. (Bug 18335)
  34 +- Added support for passing additional socket options. (Request 18418)
34 35 </notes>
35 36 <contents>
36 37 <dir baseinstalldir="Net" name="/">

0 comments on commit 3c054fc

Please sign in to comment.
Something went wrong with that request. Please try again.