Merge branch 'master' of https://github.com/PHPMailer/PHPMailer into mimesign

# Conflicts:
#	changelog.md
This commit is contained in:
Synchro 2015-03-19 18:51:18 +01:00
commit b02b573b2b
4 changed files with 63 additions and 36 deletions

View File

@ -22,6 +22,7 @@
* Add support for S/MIME signing with additional CA certificate (thanks to @IgitBuh)
* Fix incorrect MIME structure when using S/MIME signing and isMail() (#372)
* Improved checks and error messages for missing extensions
* Store and report SMTP errors more consistently
## Version 5.2.9 (Sept 25th 2014)
* **Important: The autoloader is no longer autoloaded by the PHPMailer class**

View File

@ -2844,8 +2844,17 @@ class PHPMailer
$this->error_count++;
if ($this->Mailer == 'smtp' and !is_null($this->smtp)) {
$lasterror = $this->smtp->getError();
if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) {
$msg .= '<p>' . $this->lang('smtp_error') . $lasterror['smtp_msg'] . "</p>\n";
if (!empty($lasterror['error'])) {
$msg .= $this->lang('smtp_error') . $lasterror['error'];
if (!empty($lasterror['detail'])) {
$msg .= ' Detail: '. $lasterror['detail'];
}
if (!empty($lasterror['smtp_code'])) {
$msg .= ' SMTP code: ' . $lasterror['smtp_code'];
}
if (!empty($lasterror['smtp_code_ex'])) {
$msg .= ' Additional SMTP info: ' . $lasterror['smtp_code_ex'];
}
}
}
$this->ErrorInfo = $msg;

View File

@ -157,10 +157,15 @@ class SMTP
protected $smtp_conn;
/**
* Error message, if any, for the last call.
* Error information, if any, for the last SMTP command.
* @type array
*/
protected $error = array();
protected $error = array(
'error' => '',
'detail' => '',
'smtp_code' => '',
'smtp_code_ex' => ''
);
/**
* The reply the server sent to us for HELO.
@ -248,11 +253,11 @@ class SMTP
$streamok = function_exists('stream_socket_client');
}
// Clear errors to avoid confusion
$this->error = array();
$this->setError('');
// Make sure we are __not__ connected
if ($this->connected()) {
// Already connected, generate error
$this->error = array('error' => 'Already connected to a server');
$this->setError('Already connected to a server');
return false;
}
if (empty($port)) {
@ -292,10 +297,10 @@ class SMTP
}
// Verify we connected properly
if (!is_resource($this->smtp_conn)) {
$this->error = array(
'error' => 'Failed to connect to server',
'errno' => $errno,
'errstr' => $errstr
$this->setError(
'Failed to connect to server',
$errno,
$errstr
);
$this->edebug(
'SMTP ERROR: ' . $this->error['error']
@ -362,7 +367,7 @@ class SMTP
$workstation = ''
) {
if (!$this->server_caps) {
$this->error = array('error' => 'Authentication is not allowed before HELO/EHLO');
$this->setError('Authentication is not allowed before HELO/EHLO');
return false;
}
@ -370,7 +375,7 @@ class SMTP
// SMTP extensions are available. Let's try to find a proper authentication method
if (!array_key_exists('AUTH', $this->server_caps)) {
$this->error = array( 'error' => 'Authentication is not allowed at this stage' );
$this->setError('Authentication is not allowed at this stage');
// 'at this stage' means that auth may be allowed after the stage changes
// e.g. after STARTTLS
return false;
@ -390,15 +395,14 @@ class SMTP
}
}
if (empty($authtype)) {
$this->error = array( 'error' => 'No supported authentication methods found' );
$this->setError('No supported authentication methods found');
return false;
}
self::edebug('Auth method selected: '.$authtype, self::DEBUG_LOWLEVEL);
}
if (!in_array($authtype, $this->server_caps['AUTH'])) {
$this->error = array( 'error' => 'The requested authentication method "'
. $authtype . '" is not supported by the server' );
$this->setError("The requested authentication method \"$authtype\" is not supported by the server");
return false;
}
} elseif (empty($authtype)) {
@ -442,11 +446,11 @@ class SMTP
* PROTOCOL Docs http://curl.haxx.se/rfc/ntlm.html#ntlmSmtpAuthentication
*/
require_once 'extras/ntlm_sasl_client.php';
$temp = new stdClass();
$temp = new stdClass;
$ntlm_client = new ntlm_sasl_client_class;
//Check that functions are available
if (!$ntlm_client->Initialize($temp)) {
$this->error = array('error' => $temp->error);
$this->setError($temp->error);
$this->edebug(
'You need to enable some modules in your php.ini file: '
. $this->error['error'],
@ -496,7 +500,7 @@ class SMTP
// send encoded credentials
return $this->sendCommand('Username', base64_encode($response), 235);
default:
$this->error = array( 'error' => 'Authentication method "' . $authtype . '" is not supported' );
$this->setError("Authentication method \"$authtype\" is not supported");
return false;
}
return true;
@ -570,7 +574,7 @@ class SMTP
*/
public function close()
{
$this->error = array();
$this->setError('');
$this->server_caps = null;
$this->helo_rply = null;
if (is_resource($this->smtp_conn)) {
@ -821,9 +825,7 @@ class SMTP
protected function sendCommand($command, $commandstring, $expect)
{
if (!$this->connected()) {
$this->error = array(
'error' => "Called $command without being connected"
);
$this->setError("Called $command without being connected");
return false;
}
$this->client_send($commandstring . self::CRLF);
@ -850,11 +852,11 @@ class SMTP
$this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER);
if (!in_array($code, (array)$expect)) {
$this->error = array(
'error' => "$command command failed",
'smtp_code' => $code,
'smtp_code_ex' => $code_ex,
'detail' => $detail
$this->setError(
"$command command failed",
$detail,
$code,
$code_ex
);
$this->edebug(
'SMTP ERROR: ' . $this->error['error'] . ': ' . $this->last_reply,
@ -863,7 +865,7 @@ class SMTP
return false;
}
$this->error = array();
$this->setError('');
return true;
}
@ -918,9 +920,7 @@ class SMTP
*/
public function turn()
{
$this->error = array(
'error' => 'The SMTP TURN command is not implemented'
);
$this->setError('The SMTP TURN command is not implemented');
$this->edebug('SMTP NOTICE: ' . $this->error['error'], self::DEBUG_CLIENT);
return false;
}
@ -979,7 +979,7 @@ class SMTP
public function getServerExt($name)
{
if (!$this->server_caps) {
$this->error = array('No HELO/EHLO was sent');
$this->setError('No HELO/EHLO was sent');
return null;
}
@ -991,7 +991,7 @@ class SMTP
if ($name == 'EHLO' || array_key_exists('EHLO', $this->server_caps)) {
return false;
}
$this->error = array('HELO handshake was used. Client knows nothing about server extensions');
$this->setError('HELO handshake was used. Client knows nothing about server extensions');
return null;
}
@ -1079,6 +1079,23 @@ class SMTP
return $this->do_verp;
}
/**
* Set error messages and codes.
* @param string $message The error message
* @param string $detail Further detail on the error
* @param string $smtp_code An associated SMTP error code
* @param string $smtp_code_ex Extended SMTP code
*/
protected function setError($message, $detail = '', $smtp_code = '', $smtp_code_ex = '')
{
$this->error = array(
'error' => $message,
'detail' => $detail,
'smtp_code' => $smtp_code,
'smtp_code_ex' => $smtp_code_ex
);
}
/**
* Set debug output method.
* @param string|callable $method The name of the mechanism to use for debugging output, or a callable to handle it.

View File

@ -11,13 +11,13 @@ $PHPMAILER_LANG['empty_message'] = 'Το E-Mail δεν έχει περι
$PHPMAILER_LANG['encoding'] = 'Αγνωστο Encoding-Format: ';
$PHPMAILER_LANG['execute'] = 'Αδυναμία εκτέλεσης ακόλουθης εντολής: ';
$PHPMAILER_LANG['file_access'] = 'Αδυναμία προσπέλασης του αρχείου: ';
$PHPMAILER_LANG['file_open'] = 'Σφάλμα Αρχείου: Δεν είναί δυνατό το άνοιγμα του ακόλουθου αρχείου: ';
$PHPMAILER_LANG['file_open'] = 'Σφάλμα Αρχείου: Δεν είναι δυνατό το άνοιγμα του ακόλουθου αρχείου: ';
$PHPMAILER_LANG['from_failed'] = 'Η παρακάτω διεύθυνση αποστολέα δεν είναι σωστή: ';
$PHPMAILER_LANG['instantiate'] = 'Αδυναμία εκκίνησης Mail function.';
$PHPMAILER_LANG['invalid_address'] = 'Το μήνυμα δεν αποστέλθηκε, η διεύθυνση δεν είναι έγκυρη.';
$PHPMAILER_LANG['invalid_address'] = 'Το μήνυμα δεν εστάλη, η διεύθυνση δεν είναι έγκυρη.';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer δεν υποστηρίζεται.';
$PHPMAILER_LANG['provide_address'] = 'Παρακαλούμε δώστε τουλάχιστον μια e-mail διεύθυνση παραλήπτη.';
$PHPMAILER_LANG['recipients_failed'] = 'SMTP Σφάλμα: Οι παρακάτων διευθύνσεις παραλήπτη δεν είναι έγκυρες: ';
$PHPMAILER_LANG['recipients_failed'] = 'SMTP Σφάλμα: Οι παρακάτω διευθύνσεις παραλήπτη δεν είναι έγκυρες: ';
$PHPMAILER_LANG['signing'] = 'Σφάλμα υπογραφής: ';
$PHPMAILER_LANG['smtp_connect_failed'] = 'Αποτυχία σύνδεσης στον SMTP Server.';
$PHPMAILER_LANG['smtp_error'] = 'Σφάλμα από τον SMTP Server: ';