top image
home  /  pages  /  tech tips  /  contact about

Thunderbird, KMail, cannot read mutt's sent folder

Problem

When opening mutt's sent mail mbox folder with another mailer reader, strange entries appear. The "From" header seems to be truncated. The problem is that mutt doesn't escape lines that start with "From" and are consequently misinterpreted as the beginning of a new email.

Keywords

mutt, sent, folder, From, header, thunderbird, kmail.

Solution

Use maildir.

Otherwise, use the ruby script below. It reads an mbox on stdin and spits out the same mbox on stdout, with all non-header lines that start with From prefixed by a ">" character. (It is smart enough not to quote the "From:" line of forwarded emails.)

Use at your own risk.

#!/usr/bin/ruby -w
#
# Copyright (C) 2006 Thomer M. Gil [https://thomer.com/]
#
# This program is free software. You may distribute it under the terms of
# the GNU General Public License as published by the Free Software
# Foundation, version 2.
# 
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
# 
# This little program reads an mbox and escapes lines that start with "From"
# that could possibly be misinterpreted as the start of a new email.

STDIN.each_line do |line|
  if line.match(/^From (\S+)@(\S+)\s+\S\S\S\s\S\S\S\s+\d+\s+\d\d:\d\d:\d\d\s+\d\d\d\d/)
    puts line
    next
  elsif line.match(/^From[^:](.*)/)
    puts "> #{line}"
    next
  end
  puts line
end
URL: https://thomer.com/howtos/mbox_sent.html
Copyright © 1994-2022 by Thomer M. Gil
Updated: 2006/07/23