I have just found some tens of thousands of old emails in a Linux subdirectory which I would like to upload to GMail. GMail has an IMAP interface, so if your answer is IMAP-specific, that's perfectly fine.
The emails are stored in nnml format which is sequentially numbered files, one per message. They are not mbox files (that is, there is no "^From " line at the top of the file and therefore no need to escape that in the body). I think these emails were originally written there by either Mutt or Gnus (very likely both, at various times).
What programs (or libraries) exist that do this?