Skip to content

Commit eaa68be

Browse files
committed
Add new accessors to help determine whether to use the SMTPUTF8 extension
1 parent c455af3 commit eaa68be

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Envelope.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,17 @@ public function getRecipients(): array
8585
{
8686
return $this->recipients;
8787
}
88+
89+
/**
90+
* @return bool
91+
*/
92+
public function anyAddressHasUnicodeLocalpart(): bool
93+
{
94+
if($this->sender->hasUnicodeLocalpart())
95+
return true;
96+
foreach($this->recipients as $r)
97+
if($r->hasUnicodeLocalpart())
98+
return true;
99+
return false;
100+
}
88101
}

Tests/EnvelopeTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,19 @@ public function testRecipientsFromHeaders()
127127
$this->assertEquals([new Address('[email protected]'), new Address('[email protected]'), new Address('[email protected]')], $e->getRecipients());
128128
}
129129

130+
public function testUnicodeLocalparts()
131+
{
132+
/* dømi means example and is reserved by the .fo registry */
133+
$i = new Address('info@dømi.fo');
134+
$d = new Address('dømi@dømi.fo');
135+
$e = new Envelope($i, [$i]);
136+
$this->assertFalse($e->anyAddressHasUnicodeLocalpart());
137+
$e = new Envelope($i, [$d]);
138+
$this->assertTrue($e->anyAddressHasUnicodeLocalpart());
139+
$e = new Envelope($i, [$i, $d]);
140+
$this->assertTrue($e->anyAddressHasUnicodeLocalpart());
141+
}
142+
130143
public function testRecipientsFromHeadersWithNames()
131144
{
132145
$headers = new Headers();

0 commit comments

Comments
 (0)