AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1494293
Accepted
Nicholas Saunders
Nicholas Saunders
Asked: 2023-11-29 15:00:47 +0800 CST2023-11-29 15:00:47 +0800 CST 2023-11-29 15:00:47 +0800 CST

如何使用mailutils迭代eml文件?

  • 772

如何.eml迭代文件目录?

nicholas@mordor:~$ 
nicholas@mordor:~$ mail -f foomail/foo.eml 
"/home/nicholas/foomail/foo.eml": 0 messages
nicholas@mordor:~$ 

然而,我想看到一个可供选择的列表。

command-line
  • 1 1 个回答
  • 74 Views

1 个回答

  • Voted
  1. Best Answer
    Raffa
    2023-11-30T22:56:22+08:002023-11-30T22:56:22+08:00

    你不能,EML 格式不是GNU Mailutils 支持的本地邮箱格式之一......但是,显然 MBOX 格式是。

    幸运的是,从 EML 到 MBOX 的转换很容易,这就是您可能应该考虑的。

    为了证明这一点,我使用了这个示例 EML ...所以,

    $ head *.eml
    ==> 1.eml <==
    FCC: imap://[email protected]/Sent
    X-Identity-Key: id1
    X-Account-Key: account1
    From: "[email protected]" <[email protected]>
    Subject: test confirmation
    To: [email protected], [email protected],
     [email protected], [email protected], [email protected],
     [email protected], [email protected], [email protected]
    Message-ID: <[email protected]>
    Date: Thu, 15 Aug 2019 14:54:37 +0900
    
    ==> 2.eml <==
    FCC: imap://[email protected]/Sent
    X-Identity-Key: id1
    X-Account-Key: account1
    From: "[email protected]" <[email protected]>
    Subject: test confirmation
    To: [email protected], [email protected],
     [email protected], [email protected], [email protected],
     [email protected], [email protected], mailma[email protected]
    Message-ID: <[email protected]>
    Date: Thu, 15 Aug 2019 14:54:37 +0900
    
    ==> 3.eml <==
    FCC: imap://[email protected]/Sent
    X-Identity-Key: id1
    X-Account-Key: account1
    From: "[email protected]" <[email protected]>
    Subject: test confirmation
    To: [email protected], [email protected],
     [email protected], [email protected], [email protected],
     [email protected], [email protected], [email protected]
    Message-ID: <05c18622-f2ad-cb77-2ce9-a0bbfc[email protected]>
    Date: Thu, 15 Aug 2019 14:54:37 +0900
    

    mailutils...并尝试使用(不起作用)来阅读它们:

    $ mail -V
    mail (GNU Mailutils) 3.16
    Copyright (C) 2007-2023 Free Software Foundation, inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    
    $
    $ 
    $ mail --file *.eml
    mail: -f requires at most one command line argument
    $ 
    $ 
    $ mail --file 1.eml
    "/home/ubuntu/test/dir/1.eml": 0 messages
    

    ...现在让我们将这 3 条 EML 消息转换为一个 MBOX 文件:

    $ for e in *.eml
      do
        date +"From - %a %b %d %H:%M:%S %Y" >> file.mbox
        cat "$e" >> file.mbox
        echo >> file.mbox
        done
    $ 
    $ 
    $ ls -lh
    total 20K
    -rw-rw-r-- 1 ubuntu ubuntu 2.5K Nov 30 17:48 1.eml
    -rw-rw-r-- 1 ubuntu ubuntu 2.5K Nov 30 17:48 2.eml
    -rw-rw-r-- 1 ubuntu ubuntu 2.5K Nov 30 17:48 3.eml
    -rw-rw-r-- 1 ubuntu ubuntu 7.6K Nov 30 17:49 file.mbox
    $ 
    $ 
    $ head file.mbox 
    From - Thu Nov 30 17:49:34 2023
    FCC: imap://[email protected]/Sent
    X-Identity-Key: id1
    X-Account-Key: account1
    From: "[email protected]" <[email protected]>
    Subject: test confirmation
    To: [email protected], [email protected],
     [email protected], [email protected], [email protected],
     [email protected], [email protected], [email protected]
    Message-ID: <[email protected]>
    

    ...并尝试阅读它:

    $ mail --file file.mbox 
    "/home/ubuntu/test/dir/file.mbox": 3 messages 3 new
    >N   1 piro-test@clear-co Thu Nov 30 17:49  64/2549  test confirmation
     N   2 piro-test@clear-co Thu Nov 30 17:49  64/2549  test confirmation
     N   3 piro-test@clear-co Thu Nov 30 17:49  64/2549  test confirmation
    ? 
    FCC: imap://[email protected]/Sent
    X-Identity-Key: id1
    X-Account-Key: account1
    From: "[email protected]" <[email protected]>
    Subject: test confirmation
    To: [email protected], [email protected],
     [email protected], [email protected], [email protected],
     [email protected], [email protected], [email protected]
    Message-ID: <[email protected]>
    Date: Thu, 15 Aug 2019 14:54:37 +0900
    X-Mozilla-Draft-Info: internal/draft; vcard=0; receipt=0; DSN=0; uuencode=0;
     attachmentreminder=0; deliveryformat=4
    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101
     Thunderbird/69.0
    MIME-Version: 1.0
    Content-Type: multipart/mixed;
     boundary="------------26A45336F6C6196BD8BBA2A2"
    Content-Language: en-US
    
    This is a multi-part message in MIME format.
    --------------26A45336F6C6196BD8BBA2A2
    Content-Type: text/plain; charset=utf-8; format=flowed
    Content-Transfer-Encoding: 7bit
    ? q
    Held 3 messages in /home/ubuntu/test/dir/file.mbox
    

    ...并且它有效。

    • 1

相关问题

  • 如何从命令行仅安装安全更新?关于如何管理更新的一些提示

  • 如何从命令行刻录双层 dvd iso

  • 如何从命令行判断机器是否需要重新启动?

  • 文件权限如何工作?文件权限用户和组

  • 如何在 Vim 中启用全彩支持?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve