- /**
- * SMTP server port
- * @var int
- */
- var $SMTP_PORT = 25;
-
- /**
- * SMTP reply line ending
- * @var string
- */
- var $CRLF = "\r\n";
-
- /**
- * Sets whether debugging is turned on
- * @var bool
- */
- var $do_debug; # the level of debug to perform
-
- /**
- * Sets VERP use on/off (default is off)
- * @var bool
- */
- var $do_verp = false;
-
- /**#@+
- * @access private
- */
- var $smtp_conn; # the socket to the server
- var $error; # error if any on the last call
- var $helo_rply; # the reply the server sent to us for HELO
- /**#@-*/
-
- /**
- * Initialize the class so that the data is in a known state.
- * @access public
- * @return void
- */
- function SMTP() {
- $this->smtp_conn = 0;
- $this->error = null;
- $this->helo_rply = null;
-
- $this->do_debug = 0;
- }
-
- /*************************************************************
- * CONNECTION FUNCTIONS *
- ***********************************************************/
-
- /**
- * Connect to the server specified on the port specified.
- * If the port is not specified use the default SMTP_PORT.
- * If tval is specified then a connection will try and be
- * established with the server for that number of seconds.
- * If tval is not specified the default is 30 seconds to
- * try on the connection.
- *
- * SMTP CODE SUCCESS: 220
- * SMTP CODE FAILURE: 421
- * @access public
- * @return bool
- */
- function Connect($host,$port=0,$tval=30) {
- # set the error val to null so there is no confusion
- $this->error = null;
-
- # make sure we are __not__ connected
- if($this->connected()) {
- # ok we are connected! what should we do?
- # for now we will just give an error saying we
- # are already connected
- $this->error = array("error" => "Already connected to a server");
- return false;
- }
-
- if(empty($port)) {
- $port = $this->SMTP_PORT;
- }
-
- #connect to the smtp server
- $this->smtp_conn = fsockopen($host, # the host of the server
- $port, # the port to use
- $errno, # error number if any
- $errstr, # error message if any
- $tval); # give up after ? secs
- # verify we connected properly
- if(empty($this->smtp_conn)) {
- $this->error = array("error" => "Failed to connect to server",
- "errno" => $errno,
- "errstr" => $errstr);
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": $errstr ($errno)" . $this->CRLF;
- }
- return false;
- }
-
- # sometimes the SMTP server takes a little longer to respond
- # so we will give it a longer timeout for the first read
- // Windows still does not have support for this timeout function
- if(substr(PHP_OS, 0, 3) != "WIN")
- socket_set_timeout($this->smtp_conn, $tval, 0);
-
- # get any announcement stuff
- $announce = $this->get_lines();
-
- # set the timeout of any socket functions at 1/10 of a second
- //if(function_exists("socket_set_timeout"))
- // socket_set_timeout($this->smtp_conn, 0, 100000);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce;
- }
+ /**
+ * The PHPMailer SMTP Version number.
+ */
+ const VERSION = '5.2.7';
+
+ /**
+ * SMTP line break constant.
+ */
+ const CRLF = "\r\n";
+
+ /**
+ * The SMTP port to use if one is not specified.
+ */
+ const DEFAULT_SMTP_PORT = 25;
+
+ /**
+ * The PHPMailer SMTP Version number.
+ * @type string
+ * @deprecated This should be a constant
+ * @see SMTP::VERSION
+ */
+ public $Version = '5.2.7';
+
+ /**
+ * SMTP server port number.
+ * @type int
+ * @deprecated This is only ever ued as default value, so should be a constant
+ * @see SMTP::DEFAULT_SMTP_PORT
+ */
+ public $SMTP_PORT = 25;
+
+ /**
+ * SMTP reply line ending
+ * @type string
+ * @deprecated Use the class constant instead
+ * @see SMTP::CRLF
+ */
+ public $CRLF = "\r\n";
+
+ /**
+ * Debug output level.
+ * Options: 0 for no output, 1 for commands, 2 for data and commands
+ * @type int
+ */
+ public $do_debug = 0;
+
+ /**
+ * The function/method to use for debugging output.
+ * Options: 'echo', 'html' or 'error_log'
+ * @type string
+ */
+ public $Debugoutput = 'echo';
+
+ /**
+ * Whether to use VERP.
+ * @type bool
+ */
+ public $do_verp = false;
+
+ /**
+ * The SMTP timeout value for reads, in seconds.
+ * @type int
+ */
+ public $Timeout = 15;
+
+ /**
+ * The SMTP timelimit value for reads, in seconds.
+ * @type int
+ */
+ public $Timelimit = 30;
+
+ /**
+ * The socket for the server connection.
+ * @type resource
+ */
+ protected $smtp_conn;
+
+ /**
+ * Error message, if any, for the last call.
+ * @type string
+ */
+ protected $error = '';
+
+ /**
+ * The reply the server sent to us for HELO.
+ * @type string
+ */
+ protected $helo_rply = '';
+
+ /**
+ * The most recent reply received from the server.
+ * @type string
+ */
+ protected $last_reply = '';
+
+ /**
+ * Constructor.
+ * @access public
+ */
+ public function __construct()
+ {
+ $this->smtp_conn = 0;
+ $this->error = null;
+ $this->helo_rply = null;