<?php
$valid = array(
1 => '[email protected]',
2 => '[email protected]',
3 => '[email protected]',
4 => 'test@example',
5 => '[email protected]',
6 => '[email protected]',
7 => '[email protected]',
8 => "!#$%&'*+-/=?^_`{|}[email protected]",
9 => '[email protected]',
10 => '[email protected]',
10 => 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl@example.com',
11 => 'test@abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.com',
11 => 'test@example.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk',
12 => 'a@a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v',
13 => '"test"@example.com',
14 => '"test@test"@example.com',
15 => '"test"[email protected]',
16 => 'test@[255.255.255.255]',
17 => 'test@[IPv6:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF]',
18 => 'test@[IPv6:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF::FFFF]',
19 => 'test@[IPv6:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:255.255.255.255]',
20 => 'test@[IPv6:FFFF:FFFF:FFFF:FFFF:FFFF::255.255.255.255]',
21 => ' test @ example . com ',
22 => '(comment)[email protected]',
23 => '((nested)comment)[email protected]',
24 => 'test@(comment)[255.255.255.255]',
25 => '"My name".is."Michael" (and I am (really) awesome) @ ("That\'s what she said") example . com',
);
$invalid = array(
1 => 'test',
2 => 'test@',
3 => '@example.com',
4 => '[email protected]',
5 => '[email protected]',
6 => '[email protected]',
7 => '[email protected]',
8 => "té[email protected]",
9 => '"[email protected]',
10 => 'test"@example.com',
10 => '"\"@example.com',
11 => '"test"account"@example.com',
12 => 'a@a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x',
13 => '"test"[email protected]',
14 => 'test\@[email protected]',
15 => 'test@exam!ple.com',
16 => 'test@[255.255.255.256]',
17 => 'test@[IPv6:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF]',
18 => 'test@[IPv6:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF::FFFF:FFFF]',
19 => 'test@[IPv6:FFFF:FFFF:FFFF:FFFF:FFFF:255.255.255.255]',
20 => 'test@[IPv6:FFFF:FFFF:FFFF:FFFF:FFFF::FFFF:255.255.255.255]',
21 => 'test [email protected]',
22 => '([email protected]',
23 => '((nestedcomment)[email protected]',
24 => 'test@[255(comment).255.255.255]',
25 => ' @ ',
);
include 'EmailAddressValidator.php';
foreach ($valid as $address)
{
if (!EmailAddressValidator::setEmailAddress($address, 5322)->isValid())
{
echo 'Incorrect result: ' . $address . ' is a <strong>valid</strong> address.<br />';
}
}
foreach ($invalid as $address)
{
if (EmailAddressValidator::setEmailAddress($address, 5322)->isValid())
{
echo 'Incorrect result: ' . $address . ' is an <strong>invalid</strong> address.<br />';
}
}
|