Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined property: stdClass::$host #247

Closed
putnik opened this issue May 28, 2018 · 2 comments
Closed

Undefined property: stdClass::$host #247

putnik opened this issue May 28, 2018 · 2 comments
Assignees
Labels
needs investigation This will be tested / debugged or checked out.

Comments

@putnik
Copy link

putnik commented May 28, 2018

Similar to what was in issue #149.

If the header contains an incorrect value, e.g.

From: http://example.com@noreply

then the imap_rfc822_parse_headers() function returns such an array:

array(3) {
  [0] =>
  class stdClass#3 (1) {
    public $mailbox =>
    string(4) "http"
  }
  [1] =>
  class stdClass#4 (2) {
    public $mailbox =>
    string(13) "//example.com"
    public $host =>
    string(7) "noreply"
  }
  [2] =>
  class stdClass#5 (0) {
  }
}

So host doesn't exist in first element in src/PhpImap/Mailbox.php at line 550:

$header->fromAddress = strtolower($head->from[0]->mailbox . '@' . $head->from[0]->host);
@StApostol
Copy link

I also get this error when getting the message with header
From: =?UTF-8?Q?first_part:_second_part?= <info@somesite.com>

"from": array:3 [
    0 => {
      "mailbox": "=?UTF-8?Q?first_part"
    }
    1 => {
      "personal": "_second_part?="
      "mailbox": "info"
      "host": "somesite.com"
    }
    2 => {}
  ]

@Sebbo94BY Sebbo94BY self-assigned this Apr 30, 2019
@Sebbo94BY Sebbo94BY added the needs investigation This will be tested / debugged or checked out. label Apr 30, 2019
@Sebbo94BY
Copy link
Collaborator

http://example.com@noreply is no valid and RFC conform email address. I'm not sure, how you could even receive such an email header.

However, this explains, why the imap_rfc822_parse_headers() function is unable to get the correct values.

I've just committed a change to grab these information from array 0 (preferred) or 1. If none of both contains the searched value, it will be set to NULL.

Please note, that this library will NOT check, if the values are RFC conform and valid or not. You should already make sure at your mail server, that you only send / receive RFC conform emails.

Sebbo94BY added a commit that referenced this issue May 5, 2019
- Updated README
- Move phpunit to require-dev
- Add note about installing dev dependencies in README
- Replaced spaces with tabs
- Added PHPUnit tests for MIME decoding
- Updated formatting of PHPUnit function testParsedDateTimeWithEmptyHeaderDate()
- Issue #209: Function to parse datetime correctly RFC2822
- Issue #280: Added 'Sender' to headers and added additional if-conditions 
- Issue #115: getMail() method returns an object even for nonexistent mail ID
- Issue #273: Added connection check to example
- Issue #227: Added Failed-Recipients to IncomingMailHeader
- Issue #140, #246: Improved exception handling and added PHPUnit test
- Issue #140: Added PHPUnit test for testing ConnectionException
- Issue #140: Improved exception / error handling and improved / added PHPUnit tests
- Issue #154: Added ability to change the imap_search option from SE_UID to SE_FREE and added PHPUnit tests
- Issue #306: Added support for US-ASCII and added ability to disable serverEncoding for searchMailbox()
- Imported missing namespaces to avoid 'unknown class' error messages
- Issue #86: Simplified and improved one replace regex for attachment file names
- Issue #247: Improved grabbing of fromName, fromHost, senderName and senderHost
- Issue #39, #71, #229: Fixed body content gets incorrectly processed as attachments
- Issue #122, #150, #167: Added ability to skip processing of attachments to increase performance, when attachments are not required
- PR #284: Added missing PHPUnit tests
- Issue #122, #150, #167: Lazy load message text and attachments data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation This will be tested / debugged or checked out.
Projects
None yet
Development

No branches or pull requests

3 participants