liuch / dmarc-srg

A php parser, viewer and summary report generator for incoming DMARC reports.
GNU General Public License v3.0
213 stars 31 forks source link

Error - Bad Message Number #116

Closed andrewhenke closed 3 months ago

andrewhenke commented 5 months ago

When I run the fetch_reports utility from the command line, I frequently encounter the following error nearly every single time I fetch the latest reports.

dmarc-srg [error]: ErrorException: imap_fetchstructure(): Bad message number in <REMOVED FOR PRIVACY>/classes/Mail/MailMessage.php:98
Stack trace:
#0 [internal function]: {closure}()
#1 <REMOVED FOR PRIVACY>/classes/Mail/MailMessage.php(98): imap_fetchstructure()
#2 <REMOVED FOR PRIVACY>/classes/Mail/MailMessage.php(71): Liuch\DmarcSrg\Mail\MailMessage->ensureAttachment()
#3 <REMOVED FOR PRIVACY>/classes/Sources/MailboxSource.php(83): Liuch\DmarcSrg\Mail\MailMessage->validate()
#4 <REMOVED FOR PRIVACY>/classes/Report/ReportFetcher.php(121): Liuch\DmarcSrg\Sources\MailboxSource->current()
#5 <REMOVED FOR PRIVACY>/utils/fetch_reports.php(174): Liuch\DmarcSrg\Report\ReportFetcher->fetch()
#6 {main}
-----
Error: imap_fetchstructure(): Bad message number (-1)
-----
ErrorException: imap_fetchstructure(): Bad message number in <REMOVED FOR PRIVACY>/classes/Mail/MailMessage.php:98
Stack trace:
#0 [internal function]: {closure}()
#1 <REMOVED FOR PRIVACY>/classes/Mail/MailMessage.php(98): imap_fetchstructure()
#2 <REMOVED FOR PRIVACY>/classes/Mail/MailMessage.php(71): Liuch\DmarcSrg\Mail\MailMessage->ensureAttachment()
#3 <REMOVED FOR PRIVACY>/classes/Sources/MailboxSource.php(83): Liuch\DmarcSrg\Mail\MailMessage->validate()
#4 <REMOVED FOR PRIVACY>/classes/Report/ReportFetcher.php(121): Liuch\DmarcSrg\Sources\MailboxSource->current()
#5 <REMOVED FOR PRIVACY>/utils/fetch_reports.php(174): Liuch\DmarcSrg\Report\ReportFetcher->fetch()
#6 {main}

Please let me know if I can provide any additional information or details!

liuch commented 5 months ago

Hello, Could you show me the $fetcher => mailboxes section from your configuration file?

andrewhenke commented 5 months ago
image
liuch commented 5 months ago

Thank you for the information. I have a pair more questions:

bend86 commented 5 months ago

Dear,

I add the same problem. I fixed it by working on messages UID instead of sequencial id. (UID order does not change whatever happens).

Adding flags FT_UID, CP_UID, ST_UID to following calls is working for me.

image

andrewhenke commented 5 months ago

Thank you for the information. I have a pair more questions:

  • Is it possible that when this error occurs there were other IMAP sessions where messages were deleted or moved from the mailbox?

  • When this error occurs are there any unprocessed mail messages left? If yes, are they correct incoming dmarc reports?

Hello, and my apologies for the delay in response.

The imap connection I utilize is only for accessing the DMARC reports and no other connections would be present.

Likewise, yes, there are outstanding reports to be ingested and they are properly formatted.

bend86 commented 5 months ago

Dear, for me there was only dmarc reports in the mailbox, unprocessed. Nothing else. It failed systematically, after a few messages parsed (3-4). For information: i use a gmail mailbox

The fix by use of UID let me think there could be some shift in the message index when some operations are done.

Hope it helps

liuch commented 5 months ago

Thank you all. It looks like some email servers don't follow the standard. I'll fix it soon.

liuch commented 5 months ago

done.

andrewhenke commented 5 months ago

I'll give it a test it the morning and let you know how it functions for me!

liuch commented 4 months ago

Any news on this issue? May I close this?

liuch commented 3 months ago

I'm closing this then. Feel free to reopen it if the issue is still relevant.