Skip to content

Commit

Permalink
Message: From header can be absent
Browse files Browse the repository at this point in the history
  • Loading branch information
Slamdunk committed Oct 12, 2017
1 parent 63d472b commit 93a150c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Message/AbstractMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ final public function getId(): string
/**
* Get message sender (from headers).
*
* @return EmailAddress
* @return null|EmailAddress
*/
final public function getFrom(): EmailAddress
final public function getFrom()
{
return $this->getHeaders()->get('from');
}
Expand Down
4 changes: 2 additions & 2 deletions src/Message/BasicMessageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public function getId(): string;
/**
* Get message sender (from headers).
*
* @return EmailAddress
* @return null|EmailAddress
*/
public function getFrom(): EmailAddress;
public function getFrom();

/**
* Get To recipients.
Expand Down
8 changes: 8 additions & 0 deletions tests/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,14 @@ public function testInlineAttachment()
$this->assertNull($inline->getFilename());
}

public function testMissingFromHeader()
{
$this->mailbox->addMessage($this->getFixture('missing_from'));
$message = $this->mailbox->getMessage(1);

$this->assertNull($message->getFrom());
}

public function testAttachmentMustNotBeCharsetDecoded()
{
$parts = [];
Expand Down

0 comments on commit 93a150c

Please sign in to comment.