diff options
Diffstat (limited to 'test/it_mail.t')
-rwxr-xr-x | test/it_mail.t | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/test/it_mail.t b/test/it_mail.t index 7e892c2..6aefd84 100755 --- a/test/it_mail.t +++ b/test/it_mail.t @@ -56,6 +56,12 @@ is( "Don't remove quoting characters from realname when it contains a quotable character" ); +is( + $mail->addrlist_escape('"Alfred E. Neuman" <t€st@sör.ch>', true), + '"Alfred E. Neuman" <t€st@xn--sr-fka.ch>', + "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 <sömeone@example.com>, "Alfred E. Neuman" <neuman@example.com>, "Schmitt, Sören" <schmitt@example.com>', @@ -95,10 +101,23 @@ is( ); is( - it_mail::address_error('neuman@example.com, <neuman@example.com>, "Neuman, Alfred E." <neuman@example.com>, aneuman, "<neuman@example>" <neuman@example.com>', " neumann@example.com"), + it_mail::address_error('neuman@example.com, <neuman@example.com>, "Neuman, Alfred E." <neuman@example.com>, aneuman, "<neuman@example>" <neuman@example.com>, " neumann@example.com", "www@search.ch".foo.bar@local.ch, test@sör.ch'), null, "Accept valid e-mail addresses" ); -foreach (['neuman@example', '"neuman@example.com" <neuman@example>', '<neuma@example.com'] as $email) +foreach (['neuman@example', '"neuman@example.com" <neuman@example>', '<neuma@example.com', 'shaqroot.@yahoo.com'] as $email) +{ isnt(it_mail::address_error($email), null, "Reject invalid e-mail address $email"); + foreach (it_mail::addrlist_split($email) as list($dummy, $email)) + is(it_mail::check_email($email), IT_MAIL_CHECKEMAIL_INVALID, "check_email rejects invalid email address $email too"); +} + +is(it_mail::check_email('test@sör.ch'), IT_MAIL_CHECKEMAIL_OK, "check_email accepts valid email address with idn domain"); + +is(it_mail::email_split('test@sör.ch'), ['test', 'sör.ch'], 'email_split test@sör.ch'); +is(it_mail::email_split('"test@local.ch".foo.bar@search.ch'), ['"test@local.ch".foo.bar', 'search.ch'], 'email_split "test@local.ch".foo.bar@search.ch'); +is(it_mail::email_split('aneuman'), ['aneuman', ''], 'email_split aneuman'); + +is(it_mail::email_escape('test@sör.ch'), 'test@xn--sr-fka.ch', 'idn encode domain sör.ch'); +is(it_mail::email_escape('أحمد@مثال.آزمایشی'), 'أحمد@xn--mgbh0fb.xn--hgbk6aj7f53bba', 'idn encode domain ﻢﺛﺎﻟ.ﺁﺰﻣﺎﯿﺸﯾ'); |