smtp : update docComments
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2724 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
62
smtp.php
62
smtp.php
@@ -6,33 +6,46 @@
|
|||||||
/** Allow to send mails by smtp */
|
/** Allow to send mails by smtp */
|
||||||
class smtp
|
class smtp
|
||||||
{
|
{
|
||||||
/** Debug mode */
|
/** Debug mode
|
||||||
|
*/
|
||||||
public $debug = 0;
|
public $debug = 0;
|
||||||
/** The debug file used to store all the communication between the client and
|
/** The debug file used to store all the communication between the client and
|
||||||
* the server. The file contains the passwords if used ! */
|
* the server. The file contains the passwords if used !
|
||||||
|
*/
|
||||||
public $debugFile = "/tmp/debugSMTP";
|
public $debugFile = "/tmp/debugSMTP";
|
||||||
/** The authentication user allow to send SMTP mails */
|
/** The authentication user allow to send SMTP mails
|
||||||
|
*/
|
||||||
public $user = null;
|
public $user = null;
|
||||||
/** The authentication password allow to send SMTP mails */
|
/** The authentication password allow to send SMTP mails
|
||||||
|
*/
|
||||||
public $password = null;
|
public $password = null;
|
||||||
/** The SMTP server name or IP */
|
/** The SMTP server name or IP
|
||||||
|
*/
|
||||||
public $server = "127.0.0.1";
|
public $server = "127.0.0.1";
|
||||||
/** The SMTP port */
|
/** The SMTP port
|
||||||
public $port = 25;
|
*/
|
||||||
/** The SMTPS support by tunnelling the session in SSL transport */
|
public $port = false;
|
||||||
|
/** The SMTPS support by tunnelling the session in SSL transport
|
||||||
|
*/
|
||||||
public $ssl = false;
|
public $ssl = false;
|
||||||
/** Check the certification chain in SSL mode */
|
/** Check the certification chain in SSL mode
|
||||||
|
*/
|
||||||
public $sslCheck = true;
|
public $sslCheck = true;
|
||||||
/** The Timeout between the answer of the SMTP server. If the server don't
|
/** The Timeout between the answer of the SMTP server. If the server don't
|
||||||
* 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 = "may";
|
||||||
/** Check the certificate in STARTTLS */
|
/** Check the certificate in STARTTLS
|
||||||
|
*/
|
||||||
public $starttlsCheck = false;
|
public $starttlsCheck = false;
|
||||||
/** 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
|
||||||
|
*/
|
||||||
private $smtpStream = null;
|
private $smtpStream = null;
|
||||||
|
|
||||||
/** Connect to the SMTP server */
|
/** Connect to the SMTP server */
|
||||||
@@ -44,6 +57,13 @@ class smtp
|
|||||||
$this->server = "tls://$this->server";
|
$this->server = "tls://$this->server";
|
||||||
$context["ssl"]["verify_peer_name"] = $this->sslCheck;
|
$context["ssl"]["verify_peer_name"] = $this->sslCheck;
|
||||||
$context["ssl"]["verify_peer"] = $this->sslCheck;
|
$context["ssl"]["verify_peer"] = $this->sslCheck;
|
||||||
|
if ($this->port === false)
|
||||||
|
$this->port = 465;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($this->port === false)
|
||||||
|
$this->port = 25;
|
||||||
}
|
}
|
||||||
$mainContext = stream_context_create ($context);
|
$mainContext = stream_context_create ($context);
|
||||||
$this->debug ("####SMTP Connection to $this->server:$this->port (".
|
$this->debug ("####SMTP Connection to $this->server:$this->port (".
|
||||||
@@ -141,7 +161,8 @@ class smtp
|
|||||||
return $this->putLine ("$completeMail.\r\n");
|
return $this->putLine ("$completeMail.\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Disconnect from the SMTP server */
|
/** Disconnect from the SMTP server
|
||||||
|
*/
|
||||||
public function disconnect ()
|
public function disconnect ()
|
||||||
{
|
{
|
||||||
if ($this->smtpStream === null)
|
if ($this->smtpStream === null)
|
||||||
@@ -152,7 +173,8 @@ class smtp
|
|||||||
fclose ($this->smtpStream);
|
fclose ($this->smtpStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Reset the session to start a new mail in the same SMTP connection */
|
/** Reset the session to start a new mail in the same SMTP connection
|
||||||
|
*/
|
||||||
public function reset ()
|
public function reset ()
|
||||||
{
|
{
|
||||||
if ($this->smtpStream === null)
|
if ($this->smtpStream === null)
|
||||||
@@ -162,7 +184,8 @@ class smtp
|
|||||||
$this->putLine ("RSET\r\n");
|
$this->putLine ("RSET\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Send something to the SMTP server. Wait the acknoledgement line */
|
/** Send something to the SMTP server. Wait the acknoledgement line
|
||||||
|
*/
|
||||||
private function putLine ($data)
|
private function putLine ($data)
|
||||||
{
|
{
|
||||||
$this->debug ("> $data");
|
$this->debug ("> $data");
|
||||||
@@ -170,7 +193,8 @@ class smtp
|
|||||||
return $this->getLine ($data);
|
return $this->getLine ($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Wait something from the server */
|
/** Wait something from the server
|
||||||
|
*/
|
||||||
private function getLine ($message = "")
|
private function getLine ($message = "")
|
||||||
{
|
{
|
||||||
$this->debug ("Waiting for ".rtrim ($message)." answer\n", 2);
|
$this->debug ("Waiting for ".rtrim ($message)." answer\n", 2);
|
||||||
@@ -199,6 +223,8 @@ class smtp
|
|||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Save the connection debug in file
|
||||||
|
*/
|
||||||
private function debug ($message, $priority = 1)
|
private function debug ($message, $priority = 1)
|
||||||
{
|
{
|
||||||
if ($this->debug == false)
|
if ($this->debug == false)
|
||||||
|
|||||||
Reference in New Issue
Block a user