

my machine lags yours by about 7-8 generations and has zero problems with the same task. I’ve imported 15+ 20+ years worth of emails from multiple gmail accounts into a local server’s dovecot IMAP server (and thunderbird has a local copy). no part of that thing freezes or does anything of the sort OP describes.
ixnay on anything but the vanillaest of the vanillas and that goes triple for bazzite and friends. you don’t want “intriguing” shit left behind to take care of pops, that’s a thing for you to play and experiment with.
your solution is already staring you in the face: the ubuntu you left behind persevered even under those circumstances. either fix it and update it or install a fresh one, with a tweak here and there. and don’t touch nothing else…