From 0ce73c50d8e0ee2e9a61125489b75e66cd8b6a3c Mon Sep 17 00:00:00 2001 From: Christian Scherm Date: Wed, 5 Sep 2018 11:54:14 +0200 Subject: [PATCH] Old versions of the ICU library do not define the constant INTL_IDNA_VARIANT_UTS46 To prevent "Address in mailbox does not comply with RFC 2822" --- lib/private/Mail/Mailer.php | 6 +++++- lib/private/Mail/Message.php | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php index 8f9a1c96e3b..43958c35894 100644 --- a/lib/private/Mail/Mailer.php +++ b/lib/private/Mail/Mailer.php @@ -149,7 +149,11 @@ protected function convertEmail($email) { } list($name, $domain) = \explode('@', $email, 2); - $domain = \idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46); + if (\defined('INTL_IDNA_VARIANT_UTS46')) { + $domain = \idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46); + } else { + $domain = \idn_to_ascii($domain); + } return $name.'@'.$domain; } diff --git a/lib/private/Mail/Message.php b/lib/private/Mail/Message.php index a691d0e786d..12633ff76ad 100644 --- a/lib/private/Mail/Message.php +++ b/lib/private/Mail/Message.php @@ -57,11 +57,19 @@ protected function convertAddresses($addresses) { foreach ($addresses as $email => $readableName) { if (!\is_numeric($email)) { list($name, $domain) = \explode('@', $email, 2); - $domain = \idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46); + if (\defined('INTL_IDNA_VARIANT_UTS46')) { + $domain = \idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46); + } else { + $domain = \idn_to_ascii($domain); + } $convertedAddresses[$name.'@'.$domain] = $readableName; } else { list($name, $domain) = \explode('@', $readableName, 2); - $domain = \idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46); + if (\defined('INTL_IDNA_VARIANT_UTS46')) { + $domain = \idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46); + } else { + $domain = \idn_to_ascii($domain); + } $convertedAddresses[$email] = $name.'@'.$domain; } }