#!/www/server/bin/php -qC addrlist_encode('éxample@example.com', true), 'éxample@example.com', "Don't escape plain email addresses in email headers" ); is( $mail->header_encode('éxample@example.com'), '=?utf-8?Q?=C3=A9xample@example.com?=', "Escape plain email in non-email headers" ); is( $mail->header_encode('search.ch e-mail code d\'accès'), version_compare(PHP_VERSION, '7.2.11') < 0 ? '=?utf-8?B?c2VhcmNoLmNoIGUtbWFpbCBjb2RlIGQnYWNjw6hz?=' : '=?utf-8?Q?search.ch=20e-mail=20code=20d\'acc=C3=A8s?=', "Use base64 encoding when php iconv fails with quoted-printable (workaround for php bug #53891)" ); is( $mail->addrlist_encode('Èxample User <èxample@example.com>', true), '=?utf-8?Q?=C3=88xample=20User?= <èxample@example.com>', "Escape name but not email in email headers" ); is( $mail->addrlist_encode('Example User ', true), 'Example User ', "Don't escape characters that don't need escaping" ); is( $mail->addrlist_encode('example@example.com, éxample@example.com, Sömeone Ëlse ', true), 'example@example.com, éxample@example.com, =?utf-8?Q?S=C3=B6meone=20=C3=8Blse?= ', "Don't escape email addresses but escape realnames" ); is( $mail->addrlist_encode('"Alfred E. Neuman" ', true), '"Alfred E. Neuman" ', "Don't remove quoting characters from realname" ); is( $mail->addrlist_encode('"Schmitt, Sören" ', true), '=?utf-8?Q?"Schmitt,=20S=C3=B6ren"?= ', "Don't remove quoting characters from realname when it contains a quotable character" ); is( $mail->addrlist_encode('"Alfred E. Neuman" ', true), '"Alfred E. Neuman" ', "Convert domain in email to idn version" ); $mail = new it_mail([ 'From' => 'Someone Ïmportant <ïmportant@search.ch>', 'To' => 'éxample@example.com, example@example.com, Sömeone Ëlse , "Alfred E. Neuman" , "Schmitt, Sören" ', 'Cc' => 'éxample@example.com, example@example.com, Sömeone Ëlse , "Alfred E. Neuman" , "Schmitt, Sören" ', 'Bcc' => 'éxample@example.com, example@example.com, Sömeone Ëlse , "Alfred E. Neuman" , "Schmitt, Sören" ', 'Subject' => "§önÐë®z€ı¢ħèṇ" ]); is( $mail->to[0], 'éxample@example.com, example@example.com, =?utf-8?Q?S=C3=B6meone=20=C3=8Blse?= , "Alfred E. Neuman" , =?utf-8?Q?"Schmitt,=20S=C3=B6ren"?= ', 'Escape To: field as addrlist' ); is( $mail->cc[0], 'éxample@example.com, example@example.com, =?utf-8?Q?S=C3=B6meone=20=C3=8Blse?= , "Alfred E. Neuman" , =?utf-8?Q?"Schmitt,=20S=C3=B6ren"?= ', 'Escape Cc: field as addrlist' ); is( $mail->bcc[0], 'éxample@example.com, example@example.com, =?utf-8?Q?S=C3=B6meone=20=C3=8Blse?= , "Alfred E. Neuman" , =?utf-8?Q?"Schmitt,=20S=C3=B6ren"?= ', 'Escape Bcc: field as addrlist' ); is( $mail->header_values[0], '=?utf-8?Q?Someone=20=C3=8Fmportant?= <ïmportant@search.ch>', 'Escape From: field as addrlist' ); is( $mail->subject, "§önÐë®z€ı¢ħèṇ", "Don't escape Subject: field on instanziation" ); is( it_mail::address_error('neuman@example.com, , "Neuman, Alfred E." , aneuman, "" , " neumann@example.com", "www@search.ch".foo.bar@local.ch, test@sör.ch, müller@search.ch'), null, "Accept valid e-mail addresses" ); foreach (['neuman@example', '"neuman@example.com" ', '