Skip to content

Commit 961bc6a

Browse files
committed
[Mime] allow non-ASCII characters in local part of email
1 parent cd17611 commit 961bc6a

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/Symfony/Component/Mime/Encoder/IdnAddressEncoder.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,21 @@
1111

1212
namespace Symfony\Component\Mime\Encoder;
1313

14-
use Symfony\Component\Mime\Exception\AddressEncoderException;
15-
1614
/**
1715
* An IDN email address encoder.
1816
*
1917
* Encodes the domain part of an address using IDN. This is compatible will all
2018
* SMTP servers.
2119
*
22-
* This encoder does not support email addresses with non-ASCII characters in
23-
* local-part (the substring before @).
20+
* Note: It leaves the local part as is. In case there are non-ASCII characters
21+
* in the local part then it depends on the SMTP Server if this is supported.
2422
*
2523
* @author Christian Schmidt
2624
*/
2725
final class IdnAddressEncoder implements AddressEncoderInterface
2826
{
2927
/**
3028
* Encodes the domain part of an address using IDN.
31-
*
32-
* @throws AddressEncoderException If local-part contains non-ASCII characters
3329
*/
3430
public function encodeString(string $address): string
3531
{
@@ -38,10 +34,6 @@ public function encodeString(string $address): string
3834
$local = substr($address, 0, $i);
3935
$domain = substr($address, $i + 1);
4036

41-
if (preg_match('/[^\x00-\x7F]/', $local)) {
42-
throw new AddressEncoderException(sprintf('Non-ASCII characters not supported in local-part os "%s".', $address));
43-
}
44-
4537
if (preg_match('/[^\x00-\x7F]/', $domain)) {
4638
$address = sprintf('%s@%s', $local, idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46));
4739
}

0 commit comments

Comments
 (0)