微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何将邮箱拆分为单个文件?

我想通过bash命令将我的收件箱分成不同的文件(每个消息一个文件),或者可能是Java中的简单程序。 我该怎么做?

WBR,Thanx。

我可以使用有效的电子邮件地址作为linux目录名称吗?

在没有用户干预的情况下使用apt-get安装mailutils

如何自动在bash / zsh中提供(新邮件通知

Mutt命令的多个头

Mailx发送html消息

只要使用formail 。 formail是一个程序,它可以处理邮箱,为邮箱中的每个邮件运行一些操作,分离邮件等等。

更多信息: http : //www.manpagez.com/man/1/formail/

如果你只想分开一个邮箱分开文件,我会建议这样的解决方案:

$ cat $MAIL | formail -ds sh -c 'cat > msg.$FILENO'

从男人:

FILENO While splitting,formail assigns the message number currently being output to this variable. By presetting FILENO,you can change the initial message number being used and the width of the zero-padded output. If FILENO is unset it will default to 000. If FILENO is non-empty and does not contain a number,FILENO gen- eration is disabled.

Git也可以做到这一点,例如

wget ftp://lists.gnu.org/bug-tar/2014-09 git mailsplit -o. 2014-09

如果你没有formail,你也可以使用这个Perl oneliner(从这里复制,并在我需要拆分的Thunderbird收件箱中测试)

perl -pe 'open STDOUT,">out".++$n if /^From /' < $IN > before_first

或者,有0填充的数字:

perl -pe 'open STDOUT,sprintf(">m%05d.mbx",++$n) if /^From /' < $IN > before-first

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐