The Cyrus IMAP server (which is used by FastMail, FYI), is pretty picky when it comes to enforcing RFCs. When performing a recent email migration (from Zoho, which is less picky), I got a boatload of errors along the way.
With each of my messages as individual files (downloaded as “RFC822” in raw IMAP speak), the following cleaned it up:
1 |
perl -i'.bak' -pe 's/\s+$/\r\n/g' ./*.eml |
Although you can use sed as well, the command is not the prettiest due to the way it works with lines.
To be more thorough, this is what I ultimately placed in my PHP-based migration script:
1 2 |
// For FastMail and Cyrus, if the header ends in just \n (not \r\n) then we make it \r\n $message = preg_replace("/(?<!\r)\n+/m", "\r\n", $message); |
Leave a Reply