1111
1212namespace 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 */
2725final 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