Skip to content

Commit

Permalink
Name constants consistently
Browse files Browse the repository at this point in the history
Remove unnecessary POP3 properties
Merge branch 'master' into 6.0

# Conflicts:
#	src/PHPMailer.php
#	src/POP3.php
#	src/SMTP.php
  • Loading branch information
Synchro committed Dec 9, 2016
1 parent e52f61a commit 9727777
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 49 deletions.
20 changes: 11 additions & 9 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This is a major update that breaks backwards compatibility.

* **Requires PHP 5.5 or later**
* Uses the `PHPMailer\PHPMailer` namespace
* **Uses the `PHPMailer\PHPMailer` namespace**
* File structure simplified and PSR-4 compatible, classes live in the `src/` folder
* The custom autoloader has been removed: [**use composer**](https://getcomposer.org)!
* Classes & Exceptions renamed to make use of the namespace
Expand All @@ -17,15 +17,17 @@ This is a major update that breaks backwards compatibility.
* Extensive reworking of XOAUTH2, adding support for Google, Yahoo and Microsoft providers, thanks to @sherryl4george
* Major cleanup of docs and examples
* All elements previously marked as deprecated have been removed:
* `PHPMailer->Version`
* `PHPMailer->Version` (replaced with VERSION constant)
* `PHPMailer->ReturnPath`
* `PHPMailer->PluginDir`
* `PHPMailer->encodeQPphp()`
* `SMTP->CRLF`
* `SMTP->Version`
* `SMTP->SMTP_PORT`
* `POP3->CRLF`
* `POP3->Version`
* `SMTP->CRLF` (replaced with LE constant)
* `SMTP->Version` (replaced with VERSION constant)
* `SMTP->SMTP_PORT` (replaced with DEFAULT_PORT constant)
* `POP3->CRLF` (replaced with LE constant)
* `POP3->Version` (replaced with VERSION constant)
* `POP3->POP3_PORT` (replaced with DEFAULT_PORT constant)
* `POP3->POP3_TIMEOUT` (replaced with DEFAULT_TIMEOUT constant)
* NTLM authentication has been removed - it never worked anyway!
* `PHPMailer->Workstation`
* `PHPMailer->Realm`
Expand All @@ -38,8 +40,8 @@ This is a major update that breaks backwards compatibility.
* Reorder automatic AUTH mechanism selector to try most secure method first
* `Extras` classes have been removed - use alternative packages from [packagist.org](https://packagist.org) instead
* Better handling of automatic transfer encoding switch in the presence of long lines
* Simplification of address validation - now uses PHP's filter_var by default, retains advanced options
* `Debugoutput` now accepts a PSR-3 logger instance
* Simplification of address validation - now uses PHP's `FILTER_VALIDATE_EMAIL` pattern by default, retains advanced options
* `Debugoutput` can accept a PSR-3 logger instance
* To reduce code footprint, the examples folder is no longer included in composer deployments or github zip files

## Version 5.2.17 (December 9th 2016)
Expand Down
12 changes: 6 additions & 6 deletions src/POP3.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ class POP3
*
* @var string
*/
public $Version = '6.0.0';
const VERSION = '6.0.0';

/**
* Default POP3 port number.
*
* @var integer
*/
public $POP3_PORT = 110;
const DEFAULT_PORT = 110;

/**
* Default timeout in seconds.
*
* @var integer
*/
public $POP3_TIMEOUT = 30;
const DEFAULT_TIMEOUT = 30;

/**
* Debug display level.
Expand Down Expand Up @@ -174,13 +174,13 @@ public function authorise($host, $port = false, $timeout = false, $username = ''
$this->host = $host;
// If no port value provided, use default
if (false === $port) {
$this->port = $this->POP3_PORT;
$this->port = static::DEFAULT_PORT;
} else {
$this->port = (integer)$port;
}
// If no timeout value provided, use default
if (false === $timeout) {
$this->tval = $this->POP3_TIMEOUT;
$this->tval = static::DEFAULT_TIMEOUT;
} else {
$this->tval = (integer)$timeout;
}
Expand Down Expand Up @@ -224,7 +224,7 @@ public function connect($host, $port = false, $tval = 30)
set_error_handler([$this, 'catchWarning']);

if (false === $port) {
$port = $this->POP3_PORT;
$port = static::DEFAULT_PORT;
}

// connect to the POP3 server
Expand Down
68 changes: 34 additions & 34 deletions src/SMTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SMTP
*
* @var integer
*/
const DEFAULT_SMTP_PORT = 25;
const DEFAULT_PORT = 25;

/**
* The maximum line length allowed by RFC 2822 section 2.1.1
Expand Down Expand Up @@ -143,16 +143,16 @@ class SMTP
*/
public $Timelimit = 300;

/**
* @var array patterns to extract smtp transaction id from smtp reply
* Only first capture group will be use, use non-capturing group to deal with it
* Extend this class to override this property to fulfil your needs.
*/
protected $smtp_transaction_id_patterns = array(
'exim' => '/[0-9]{3} OK id=(.*)/',
'sendmail' => '/[0-9]{3} 2.0.0 (.*) Message/',
'postfix' => '/[0-9]{3} 2.0.0 Ok: queued as (.*)/'
);
/**
* @var array patterns to extract smtp transaction id from smtp reply
* Only first capture group will be use, use non-capturing group to deal with it
* Extend this class to override this property to fulfil your needs.
*/
protected $smtp_transaction_id_patterns = [
'exim' => '/[0-9]{3} OK id=(.*)/',
'sendmail' => '/[0-9]{3} 2.0.0 (.*) Message/',
'postfix' => '/[0-9]{3} 2.0.0 Ok: queued as (.*)/'
];

/**
* The socket for the server connection.
Expand Down Expand Up @@ -277,7 +277,7 @@ public function connect($host, $port = null, $timeout = 30, $options = [])
return false;
}
if (empty($port)) {
$port = self::DEFAULT_SMTP_PORT;
$port = self::DEFAULT_PORT;
}
// Connect to the SMTP server
$this->edebug(
Expand Down Expand Up @@ -1200,27 +1200,27 @@ protected function errorHandler($errno, $errmsg)
);
}

/**
* Will return the ID of the last smtp transaction based on a list of patterns provided
* in SMTP::$smtp_transaction_id_patterns.
* If no reply has been received yet, it will return null.
* If no pattern has been matched, it will return false.
* @return bool|null|string
*/
public function getLastTransactionID()
{
$reply = $this->getLastReply();

if (empty($reply)) {
return null;
}

foreach($this->smtp_transaction_id_patterns as $smtp_transaction_id_pattern) {
if(preg_match($smtp_transaction_id_pattern, $reply, $matches)) {
return $matches[1];
}
}

return false;
/**
* Will return the ID of the last smtp transaction based on a list of patterns provided
* in SMTP::$smtp_transaction_id_patterns.
* If no reply has been received yet, it will return null.
* If no pattern has been matched, it will return false.
* @return bool|null|string
*/
public function getLastTransactionID()
{
$reply = $this->getLastReply();

if (empty($reply)) {
return null;
}

foreach ($this->smtp_transaction_id_patterns as $smtp_transaction_id_pattern) {
if (preg_match($smtp_transaction_id_pattern, $reply, $matches)) {
return $matches[1];
}
}

return false;
}
}

0 comments on commit 9727777

Please sign in to comment.