Skip to content
Permalink
Browse files

Allow _ in domain names that email can be sent to.

Port changes from #11222 to 3.x. Subdomains and internal DNS allow _ to
be used.
  • Loading branch information...
markstory committed Sep 23, 2017
1 parent 13738b6 commit 8dea5d8c6a5cb01e9e0e52948c8700f55a7c4d70
Showing with 15 additions and 2 deletions.
  1. +1 −1 src/Mailer/Email.php
  2. +14 −1 tests/TestCase/Mailer/EmailTest.php
@@ -87,7 +87,7 @@ class Email implements JsonSerializable, Serializable
*
* @var string
*/
const EMAIL_PATTERN = '/^((?:[\p{L}0-9.!#$%&\'*+\/=?^_`{|}~-]+)*@[\p{L}0-9-.]+)$/ui';
const EMAIL_PATTERN = '/^((?:[\p{L}0-9.!#$%&\'*+\/=?^_`{|}~-]+)*@[\p{L}0-9-._]+)$/ui';
/**
* Recipient of the email
@@ -273,6 +273,19 @@ public function testTo()
$this->assertSame($this->Email, $result);
}
/**
* test to address with _ in domain name
*
* @return void
*/
public function testToUnderscoreDomain()
{
$result = $this->Email->to('cake@cake_php.org');
$expected = ['cake@cake_php.org' => 'cake@cake_php.org'];
$this->assertSame($expected, $this->Email->to());
$this->assertSame($this->Email, $result);
}
/**
* Data provider function for testBuildInvalidData
*
@@ -2829,7 +2842,7 @@ public function testJsonSerialize()
'mimetype' => 'image/png'
]
],
'_emailPattern' => '/^((?:[\p{L}0-9.!#$%&\'*+\/=?^_`{|}~-]+)*@[\p{L}0-9-.]+)$/ui'
'_emailPattern' => '/^((?:[\p{L}0-9.!#$%&\'*+\/=?^_`{|}~-]+)*@[\p{L}0-9-._]+)$/ui'
];
$this->assertEquals($expected, $result);

0 comments on commit 8dea5d8

Please sign in to comment.
You can’t perform that action at this time.