ddeboer / imap

Object-oriented, fully tested PHP IMAP library
MIT License
889 stars 252 forks source link

Unknown: Missing or invalid host name after @ (errflg=3) in Unknown on line 0 #308

Open peter-schmandra-yesmail opened 6 years ago

peter-schmandra-yesmail commented 6 years ago

I'm parsing emails and came across an email with a mangled from address. The script puts out the following error

"PHP Notice: Unknown: Missing or invalid host name after @ (errflg=3) in Unknown on line 0"

Upon further reading I cam across this solution

https://stackoverflow.com/questions/3378469/how-to-get-rid-of-error-messages-with-phps-imap-fetchstructure

So I added the line to /ddeboer/imap/src/Message.php Line 66 and now my exception is caught cleanly. I did not make a pull request because I am not sure exactly what this function call is doing in that context. Also, cannot provide the raw email because it's in a chinese mailbox in an obscure ISP and I cannot figure out how to download the raw source. Great repo BTW. Thanks very much.

Slamdunk commented 6 years ago

Hi, may you post the result of the call to getRawMessage() on the Message that raised the error?

peter-schmandra-yesmail commented 6 years ago

OMG, I did not even think that. However, I don't want this public. Can I zip it up and email it to u?

Slamdunk commented 6 years ago

Sure :+1:

peter-schmandra-yesmail commented 6 years ago

Is that your email in the LICENSE?

Slamdunk commented 6 years ago

Take a look at the second line of the last commit: https://github.com/ddeboer/imap/commit/00b75df6d51bcadae5e2b449a04d928322a1f6aa.patch

Slamdunk commented 6 years ago

https://github.com/ddeboer/imap/pull/309

peter-schmandra-yesmail commented 6 years ago

Encountered a similar error

PHP Notice: Unknown: Calculated RFC822.SIZE (51990) != reported size (51992) (errflg=1) in Unknown on line 0

https://stackoverflow.com/questions/20397585/imap-check-throwing-notice-when-mailbox-is-empty/38477229

Used the same solution by adding \imap_errors(); to /ddeboer/imap/src/Message.php Line 125.

Slamdunk commented 6 years ago

May you post the exact diff of how you altered this library to suppress the error please?

peter-schmandra-yesmail commented 6 years ago

From what I understand every imap_* function call has the potential to output an error notice. However the following edit suppressed the ones I was encountering. Diff is from /src/messages.php

66c65 < \imap_errors();

95,96c93 < \imap_errors(); <

126,128c122 < < \imap_errors(); <