1

How would a directory of .eml files be iterated?

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

Whereas, I'd like to see a list to select from.

1 Answers1

1

You can't, EML format is not one of the supported local mailbox formats by GNU Mailutils ... But, apparently the MBOX format is.

Luckily the conversion from EML to MBOX is easy and that's what you probably should consider.

To demonstrate that, I used this sample EML ... so,

$ head *.eml
==> 1.eml <==
FCC: imap://piro-test@mail.clear-code.com/Sent
X-Identity-Key: id1
X-Account-Key: account1
From: "piro-test@clear-code.com" <piro-test@clear-code.com>
Subject: test confirmation
To: piro.outsider.reflex+1@gmail.com, piro.outsider.reflex+2@gmail.com,
 mailmaster@example.com, mailmaster@example.org, webmaster@example.com,
 webmaster@example.org, webmaster@example.jp, mailmaster@example.jp
Message-ID: <05c18622-f2ad-cb77-2ce9-a0bbfc7d7ad0@clear-code.com>
Date: Thu, 15 Aug 2019 14:54:37 +0900

==> 2.eml <== FCC: imap://piro-test@mail.clear-code.com/Sent X-Identity-Key: id1 X-Account-Key: account1 From: "piro-test@clear-code.com" <piro-test@clear-code.com> Subject: test confirmation To: piro.outsider.reflex+1@gmail.com, piro.outsider.reflex+2@gmail.com, mailmaster@example.com, mailmaster@example.org, webmaster@example.com, webmaster@example.org, webmaster@example.jp, mailmaster@example.jp Message-ID: <05c18622-f2ad-cb77-2ce9-a0bbfc7d7ad0@clear-code.com> Date: Thu, 15 Aug 2019 14:54:37 +0900

==> 3.eml <== FCC: imap://piro-test@mail.clear-code.com/Sent X-Identity-Key: id1 X-Account-Key: account1 From: "piro-test@clear-code.com" <piro-test@clear-code.com> Subject: test confirmation To: piro.outsider.reflex+1@gmail.com, piro.outsider.reflex+2@gmail.com, mailmaster@example.com, mailmaster@example.org, webmaster@example.com, webmaster@example.org, webmaster@example.jp, mailmaster@example.jp Message-ID: <05c18622-f2ad-cb77-2ce9-a0bbfc7d7ad0@clear-code.com> Date: Thu, 15 Aug 2019 14:54:37 +0900

... and try to read them with mailutils (Doesn't Work):

$ 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

... Now let's convert those 3 EML messages to one MBOX file:

$ 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://piro-test@mail.clear-code.com/Sent
X-Identity-Key: id1
X-Account-Key: account1
From: "piro-test@clear-code.com" <piro-test@clear-code.com>
Subject: test confirmation
To: piro.outsider.reflex+1@gmail.com, piro.outsider.reflex+2@gmail.com,
 mailmaster@example.com, mailmaster@example.org, webmaster@example.com,
 webmaster@example.org, webmaster@example.jp, mailmaster@example.jp
Message-ID: <05c18622-f2ad-cb77-2ce9-a0bbfc7d7ad0@clear-code.com>

... and try to read it:

$ 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://piro-test@mail.clear-code.com/Sent
X-Identity-Key: id1
X-Account-Key: account1
From: "piro-test@clear-code.com" <piro-test@clear-code.com>
Subject: test confirmation
To: piro.outsider.reflex+1@gmail.com, piro.outsider.reflex+2@gmail.com,
 mailmaster@example.com, mailmaster@example.org, webmaster@example.com,
 webmaster@example.org, webmaster@example.jp, mailmaster@example.jp
Message-ID: <05c18622-f2ad-cb77-2ce9-a0bbfc7d7ad0@clear-code.com>
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

... and it works.

Raffa
  • 32,237