From 0e7b094a328970af2730ea3e8334deac6c12bf02 Mon Sep 17 00:00:00 2001 From: Marcus Bointon Date: Thu, 17 Oct 2024 15:51:53 +0200 Subject: [PATCH] Throw an exception if the server doesn't support SMTPUTF8 and we need it --- src/PHPMailer.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/PHPMailer.php b/src/PHPMailer.php index 18108994..e5840ebb 100644 --- a/src/PHPMailer.php +++ b/src/PHPMailer.php @@ -2098,6 +2098,11 @@ class PHPMailer if (!$this->smtpConnect($this->SMTPOptions)) { throw new Exception($this->lang('smtp_connect_failed'), self::STOP_CRITICAL); } + //If we have recipient addresses that need Unicode support, + //but the server doesn't support it, stop here + if ($this->UseSMTPUTF8 && $this->smtp->getServerExt('SMTPUTF8') === null) { + throw new Exception($this->lang('no_smtputf8'), self::STOP_CRITICAL); + } //Sender already validated in preSend() if ('' === $this->Sender) { $smtp_from = $this->From; @@ -2397,6 +2402,7 @@ class PHPMailer 'smtp_detail' => 'Detail: ', 'smtp_error' => 'SMTP server error: ', 'variable_set' => 'Cannot set or reset variable: ', + 'no_smtputf8' => 'Server does not support SMTPUTF8 needed to send to Unicode addresses', ]; if (empty($lang_path)) { //Calculate an absolute path so it can work if CWD is not here