Get all recent "From:" domains from IMAP server?

To create a Fastmail whitelist I want to create a list of all domains that I received email from recently (that I will then filter manually in a text editor). One way to achieve that might be to write a Node.js script that accesses the Fastmail IMAP server to go over the headers I guess (something I never tried, so it could be a nice experiment), but maybe there’s a faster/smarter way to achieve this?

How would you get all recent “From:” domains from your IMAP server?

A small Node.js script using node-imap was all it took :smiley: