smtp : push the STARTTLS to none by default, as the certificate of the server must be equal to the configuration.
smtp : Catch the STARTTLS errors instead of displaying a warning smtp : don't loop etrenaly if there is a smtp problem git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2722 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
19
smtp.php
19
smtp.php
@@ -25,7 +25,7 @@ class smtp
|
|||||||
* answer in this time, an exception is raised */
|
* answer in this time, an exception is raised */
|
||||||
public $timeout = 10;
|
public $timeout = 10;
|
||||||
/** Activate STARTTLS if needed. Allowed values : none, may, encrypt*/
|
/** Activate STARTTLS if needed. Allowed values : none, may, encrypt*/
|
||||||
public $starttls = "may";
|
public $starttls = "none";
|
||||||
/** The authentication methods in an array. Allowed : plain, login*/
|
/** The authentication methods in an array. Allowed : plain, login*/
|
||||||
public $authmethods = array ("plain", "login");
|
public $authmethods = array ("plain", "login");
|
||||||
/** The socket of the connection */
|
/** The socket of the connection */
|
||||||
@@ -36,7 +36,8 @@ class smtp
|
|||||||
{
|
{
|
||||||
if ($this->ssl)
|
if ($this->ssl)
|
||||||
$this->server = "tls://$this->server";
|
$this->server = "tls://$this->server";
|
||||||
$this->debug ("####SMTP Connection to $this->server:$this->port\n");
|
$this->debug ("####SMTP Connection to $this->server:$this->port (".
|
||||||
|
date ("Y/m/d H:i:s").")\n");
|
||||||
$this->smtpStream = @fsockopen ($this->server, $this->port,
|
$this->smtpStream = @fsockopen ($this->server, $this->port,
|
||||||
$errno, $errstr,
|
$errno, $errstr,
|
||||||
$this->timeout);
|
$this->timeout);
|
||||||
@@ -55,8 +56,16 @@ class smtp
|
|||||||
if ($this->starttls === "may" || $this->starttls === "encrypt")
|
if ($this->starttls === "may" || $this->starttls === "encrypt")
|
||||||
{
|
{
|
||||||
$this->putLine ("STARTTLS\r\n");
|
$this->putLine ("STARTTLS\r\n");
|
||||||
stream_socket_enable_crypto ($this->smtpStream, true,
|
// The track_errors permit to create the $php_errormsg in case of
|
||||||
STREAM_CRYPTO_METHOD_TLS_CLIENT);
|
// warning
|
||||||
|
ini_set('track_errors', 1);
|
||||||
|
if (@stream_socket_enable_crypto ($this->smtpStream, true,
|
||||||
|
STREAM_CRYPTO_METHOD_TLS_CLIENT) ===
|
||||||
|
false)
|
||||||
|
throw new \Exception (sprintf (_("Can't activate STARTTLS : %s"),
|
||||||
|
$php_errormsg), 500);
|
||||||
|
ini_set('track_errors', 0);
|
||||||
|
$this->debug ("STARTTLS ACTIVATED\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($this->starttls === "encrypt")
|
elseif ($this->starttls === "encrypt")
|
||||||
@@ -149,6 +158,8 @@ class smtp
|
|||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
$line = stream_get_line ($this->smtpStream, 1024, "\r\n");
|
$line = stream_get_line ($this->smtpStream, 1024, "\r\n");
|
||||||
|
if ($line === false)
|
||||||
|
break;
|
||||||
$meta = stream_get_meta_data ($this->smtpStream);
|
$meta = stream_get_meta_data ($this->smtpStream);
|
||||||
if ($meta["timed_out"] !== FALSE)
|
if ($meta["timed_out"] !== FALSE)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user