mirror of
https://github.com/PHPMailer/PHPMailer.git
synced 2024-09-20 01:52:15 +02:00
add details from SMTP::getError() to STARTTLS exceptions
This commit is contained in:
parent
cbfe93b75a
commit
7b4e8cdf92
@ -2143,7 +2143,8 @@ class PHPMailer
|
||||
}
|
||||
if ($tls) {
|
||||
if (!$this->smtp->startTLS()) {
|
||||
throw new Exception($this->lang('connect_host'));
|
||||
$message = $this->getSmtpErrorMessage('connect_host');
|
||||
throw new Exception($message);
|
||||
}
|
||||
//We must resend EHLO after TLS negotiation
|
||||
$this->smtp->hello($hello);
|
||||
@ -4110,6 +4111,26 @@ class PHPMailer
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an error message starting with a generic one and adding details if possible.
|
||||
*
|
||||
* @param string $base_key
|
||||
* @return string
|
||||
*/
|
||||
private function getSmtpErrorMessage($base_key)
|
||||
{
|
||||
$message = $this->lang($base_key);
|
||||
$error = $this->smtp->getError();
|
||||
if (!empty($error['error'])) {
|
||||
$message .= ' ' . $error['error'];
|
||||
if (!empty($error['detail'])) {
|
||||
$message .= ' ' . $error['detail'];
|
||||
}
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an error occurred.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user