Skip to content

Commit

Permalink
Merge pull request #829 from wmde/evil-char-mails
Browse files Browse the repository at this point in the history
Allow weird evil characeters in email domains
  • Loading branch information
gbirke committed Feb 13, 2017
2 parents a65d007 + d6e2780 commit 8bea62c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/Infrastructure/Messenger.php
Expand Up @@ -44,10 +44,11 @@ public function sendMessageToOperator( Message $messageContent, EmailAddress $re
private function createMessage( Message $messageContent, EmailAddress $recipient,
EmailAddress $replyTo = null ): Swift_Message {
$message = Swift_Message::newInstance( $messageContent->getSubject(), $messageContent->getMessageBody() );
$message->setFrom( $this->operatorAddress->getFullAddress(), $this->operatorName );
$message->setTo( $recipient->getFullAddress() );
$message->setFrom( $this->operatorAddress->getNormalizedAddress(), $this->operatorName );
$message->setTo( $recipient->getNormalizedAddress() );

if ( $replyTo ) {
$message->setReplyTo( $replyTo->getFullAddress() );
$message->setReplyTo( $replyTo->getNormalizedAddress() );
}

return $message;
Expand Down
24 changes: 21 additions & 3 deletions tests/Unit/Infrastructure/MessengerTest.php
Expand Up @@ -18,9 +18,7 @@
class MessengerTest extends \PHPUnit\Framework\TestCase {

public function testWhenSendReturnsZero_exceptionIsThrown() {
$mailTransport = $this->getMockBuilder( Swift_NullTransport::class )
->disableOriginalConstructor()
->getMock();
$mailTransport = $this->newMailTransport();

$mailTransport->expects( $this->once() )
->method( 'send' )
Expand All @@ -35,4 +33,24 @@ public function testWhenSendReturnsZero_exceptionIsThrown() {
);
}

private function newMailTransport() {
return $this->getMockBuilder( Swift_NullTransport::class )
->disableOriginalConstructor()
->getMock();
}

public function testSendToAddressWithInternationalCharacters_doesNotCauseException() {
$messenger = new Messenger(
$this->newMailTransport(),
new EmailAddress( 'hostmaster@thatoperator.com' )
);

$messenger->sendMessageToUser(
new Message( 'Test message', 'Test content' ),
new EmailAddress( 'info@m眉llerrr.de' )
);

$this->assertTrue( true );
}

}

0 comments on commit 8bea62c

Please sign in to comment.