antedebaas / Viesti-Reports

DMARC & SMTP-TLS Reports processor and visualizer and BIMI file hoster
https://docs.viestireports.com/
GNU General Public License v2.0
80 stars 16 forks source link

Feature Request: Sort imap mail by oldest first. #44

Closed sn3ak closed 2 months ago

sn3ak commented 8 months ago

I've saved my DMARC and TLS reports for years as I didn't have software to view the reports. Having found your software I set it up and had it parse the 300+ emails that were saved. The result isn't what I would have expected, as "Latest DMARC/TLS Reports" shows the oldest email first.

While looking around I stumbled on the following code from php's imap_fetch_overview page. I am wondering if you could implement something similar

<?php
$result = imap_fetch_overview($imap_stream, '1:10', 0);

usort($result, function($a, $b) {
  return($b->udate-$a->udate);
});
?> 
antedebaas commented 8 months ago

im not using imap functions directly but the php-imap library. im not sure if that supports a sorting mechanism and ill have to look into that

sn3ak commented 7 months ago

I researched this some more and found the following answer from the sources github: It appears adding rsort($mail_ids); before line 87 will handle this.

sn3ak commented 7 months ago

I dropped my database, recreated it and ran php bin/console doctrine:migrations:migrate --no-interaction --query-time then visited http://127.0.0.1/setup to create a user and finish the install. I then used webmail to set all messages as UNSEEN.

I ran the script to fetch mail, and besides the errors I am getting in #45 , I was able to import all reports, and they all appear to be in the correct order now after making the rsort change.

antedebaas commented 7 months ago

great thanks. ill have a look at this as soon as i have the time :)

antedebaas commented 2 months ago

cant reproduce