我最初安装了 Ubuntu 11.04,并使用 KMail 收发电子邮件。一切都很好。
然后我升级到了 Ubuntu 11.10。大概 KMail 也升级了。现在 KMail 根本就无法运行;我尝试的时候,它提示“无法获取资源集合”然后崩溃了。
我不介意切换到其他电子邮件客户端,但我非常希望能够恢复我存储在 KMail 中的所有电子邮件。关于如何做到这一点,有什么建议吗?
感谢任何人提供的帮助。
答案1
使用此 shell 脚本将 mdir 转换为 mbox 格式
#! /bin/sh
#
# Get a directory name as input and convert all mail files inside
# to mbox format
#
# NOTE: processing of subdirectories not yet implemented correctly:
# all mails in subfolders are put into the same mbox
# (it would be better if an mbox file will be generated for
# each subfolder)
#
# History:
# Feb 06 2001 Joerg Reinhardt
# - first edition
# Feb 07 2001 Joerg Reinhardt
# - added usage output
# Feb 12 2001 Joerg Reinhardt
# - mails not containing a 'From:' field but an 'X-From-Line:' or a
# 'Reply-To:' field are now recognised and also processed (e.g. put into
# the mbox file); this works fine for all my mails
# - added progress information
# - warning about corrupt files is now written to stderr
# Sep 8 2012 Kim Johansson
# - Time conversion to local timezone added
# - changed grep "Date:" to grep "Date: "
# check for argument or help argument respectively
if [[ ($1 == "") ||
($1 == "-h") ||
($1 == "--help") ||
($1 == "-help") ]]; then
echo "Usage: "$0" <Xfmail-mail-directory>";
fi;
# check if parameter is a directory
if [[ -d $1 ]]; then
# set target filename
dirname=`echo $1 | awk '{while(substr($0,length($0),1)=="/"){$0=substr($0,1,length($0)-1);}print $0;}'`;
mboxfile=$dirname'.mbox';
# check if directory is empty
if [[ `find $dirname -type f` == "" ]]; then
echo $dirname": directory empty."
exit 1;
fi;
# prevent automatic overwriting of target
if [[ -e $mboxfile ]]; then \
dialogtext="Write file "$mboxfile"?";
if dialog --yesno "$dialogtext" 10 60; then
clear;
rm -vf $mboxfile;
else
clear; exit 1;
fi;
fi;
echo "writing xfmail mail directory '$1' to '$mboxfile'.";
# so we can handle filnames with space
IFS=$(echo -en "\n\b")
# collect files inside Xfmail mail-directory and produce MBOX format
# target file
# for i in `find $1/* -type f -ls | cut -b 69-`; do
for i in `find $1/* -type f`; do
# output progress information
echo -n -e \\r" "
echo -n -e \\rprocessing $i
# look for senders email address in the order
# 'From:'
# 'X-From-Line:'
# 'Reply-To:'
shortfromflag='true';
fromline=`grep 'From:' $i`;
# parse 'From:' field
from=`echo $fromline | awk 'BEGIN{FS="<";}{if($0~/</) {pos=index($2,">");if(pos!=0) {print substr($2,1,pos-1);}} else {pos=index($0,":");print substr($0,pos+1);}}'`;
if [[ $from == "" ]]; then
shortfromflag='false';
fromline=`grep 'X-From-Line:' $i`;
from=`echo $fromline | awk 'BEGIN{FS="Line:";}{print $2;}'`;
if [[ $from == "" ]]; then
shortfromflag='true';
fromline=`grep 'Reply-To:' $i`;
# parse 'Reply-To:' field
from=`echo $fromline | awk 'BEGIN{FS="<";}{if($0~/</) {pos=index($2,">");if(pos!=0) {print substr($2,1,pos-1);}} else {pos=index($0,":");print substr($0,pos+1);}}'`;
if [[ $from == "" ]]; then
echo;
echo "WARNING: "$i": no 'From:' nor 'X-From-Line:' nor 'Reply-To:' field found." >&2;
continue;
fi;
fi;
fi;
if [[ $shortfromflag == "true" ]]; then
# parse date field
dateline=`grep 'Date: ' $i`;
if [[ $dateline == "" ]]; then
# set dummy date if no date field found
dateline="Date: Thu, 01 Jan 1970 00:00:00 +0000 (GMT)";
fi;
datel=`echo $dateline | cut -b7- -`
# Convert to local time
dateli=`date --date="$datel"`
# output MBOX mail header
echo "From " $from $dateli >> $mboxfile;
else
# output long MBOX mail header found in 'X-From-Line:' field
echo $from >> $mboxfile;
fi;
# output mail itself
cat $i >> $mboxfile;
done;
echo;
else
echo $1": not a directory.";
fi;
答案2
如果您的邮件框格式化很容易
cd ~/.kde/share/apps/kmail/mail/
cat file1 file2 file3 ... >>/var/spool/mail/$USER
file1 file2 file3 ...,是您的 mbox 格式的邮件文件夹(不要复制任何 .index .index.ids .index.sorted 文件)
现在,您可以通过选择本地递送从任何邮件客户端获取邮件
我使用 thunderbird:
服务器类型:Unix Movemail
服务器:localhost
这是在 Slackware 中完成的,它使用 sendmail 作为 MDA,因此你的 spool 目录可能不同。