Score:1

How do you output the contents of an .eml file [ Not including all of its metadata ] to the commandline in plaintext?

cn flag

I can do this:

cat foobar.eml 
Delivered-To: anonymous@gmail.com
Received: by 2002:a4a:6c09:0:0:0:0:0 with SMTP id q9-v6csp1498994ooc;
        Thu, 23 Aug 2018 10:00:37 -0700 (PDT)
X-Google-Smtp-Source: ANB0VdbsRmqaaUs41HCS0zliF29KjnrQqZE+srtTakEZc+PVSCUEFl8HpZfCTXRfwolCrpwIuZ3i
X-Received: by 2002:a37:61ca:: with SMTP id v193-v6mr21368476qkb.307.1535043637258;
        Thu, 23 Aug 2018 10:00:37 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1535043637; cv=none;
        d=google.com; s=arc-20160816;
        b=nNhTOOwiVbxnGokbmAWg9fp4aInzO+Q7mPC5Nzu/1gfsjq5y4JX0EDsBicLrMYCSX7
         8BifYeDYFi646D3rFxP6eja4bd2bMtWOdGDNe5R1SK2yqREU66ivi8vbnkfsuT3c+0BW
         +CM5ByXWdAHl7ySrPySaxhFNnj+/oT/TC3lss83g4KO3dslvQFmx2uTgXJwuOAde23As
         22jg6F2s9nG5uEKk02tfZ99U8Boz5AWUtpe+AmjudMP/YVhUNep8uL+9sC4WSHkPZVwG
         eDlUTgdpXE7CKOrEMfbMw/vD5elekSNdKAt92q2ooXMYZxYZC4zuMjjAkfLUAvT/0ZsV
         WXng==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=thread-index:thread-topic:content-transfer-encoding:mime-version
         :subject:message-id:cc:to:from:date:dkim-signature
         :arc-authentication-results;
        bh=kaeeCo6FPQb2D167BEzpileq9J1mjS9umYUnnWzC4fg=;
        b=HlvSPoSofaPVe2bGCcCBz2WD5iOGjyF9uNDN9bDXcqnEN/xUBgVgFSuVrLfAi0FkgH
         yChEaIu7md/1CufOpaTfFaQHIFB8x8WP4MIcu2SDSJ5dyVGL6gTTLnTmGBU2svJRw41I
         qZMDxL62KJxzmZ1sYMyOG6CiKiXA/PqH3rMy9omVTLEgQMWAJQWdHaqn2+82V7XrMJMp
         P7wZMzNKyg1QU7dnKATftQEHzR4xBvfsqSOuvdQeYQZB+xSewrY/rVw2hhtuzqKiL+s+
         Pfa6XdiP8mzGO3yHUBOfMolC1odvTJw0OhWnVS0bMx81E2PmUkxmi4MtAu4HrwfEvAYK
         VcEQ==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass (test mode) header.i=@telus.net header.s=neo header.b="l6Q+/5CE";
       spf=pass (google.com: domain of ms@telus.net designates 209.171.16.92 as permitted sender) smtp.mailfrom=ms@telus.net;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=telus.net
Return-Path: <ms@telus.net>
Received: from cmta19.telus.net (cmta19.telus.net. [209.171.16.92])
        by mx.google.com with ESMTPS id p22-v6si4646092qtn.292.2018.08.23.10.00.36
        for <anonymous@gmail.com>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Thu, 23 Aug 2018 10:00:37 -0700 (PDT)
Received-SPF: pass (google.com: domain of ms@telus.net designates 209.171.16.92 as permitted sender) client-ip=209.171.16.92;
Authentication-Results: mx.google.com;
       dkim=pass (test mode) header.i=@telus.net header.s=neo header.b="l6Q+/5CE";
       spf=pass (google.com: domain of ms@telus.net designates 209.171.16.92 as permitted sender) smtp.mailfrom=ms@telus.net;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=telus.net
Received: from mtlp000024.email.telus.net ([172.20.100.250])
        by cmsmtp with SMTP
        id ssxyfjNXWwgrmssxyfNVR7; Thu, 23 Aug 2018 11:00:14 -0600
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telus.net; s=neo;
        t=1535043636; bh=kaeeCo6FPQb2D167BEzpileq9J1mjS9umYUnnWzC4fg=;
        h=Date:From:To:Cc:Subject;
        b=l6Q+/5CElxHMO0AAM94M3WgcPJOzxPDYuDtmgJm5tv/sfSaC1M4du8YDwiesmYVSe
         5addUv9uuzozrqXIr4VRjEzeghy+mGXXz+37xtTGDjMiOCTfC2XQQiwGMN4xnxIksE
         x7ZikbTK92HCCw9YNEtPU2Jx+0A2pbkE1IJZLkNMm4ZbfKSpykcZxMezNrd2jqbhqr
         M0YWVFGK4ssyY90SAA1bUrs2TbR6/aiVx+MVTfKMRMDcgWxZkQNH8hi3gMFB6qo1Yj
         vPPjig8L9I9ittJzJhua0hQ5qoiczV7EuuIUmj632ELBMqNpxjZ+eoTfkopqdVrMm0
         Re8l6PofcDSXw==
X-Authority-Analysis: v=2.3 cv=D4zz1cZj c=1 sm=1 tr=0
 a=4bd358MHcbnBkp+IcMzszA==:117 a=FKkrIqjQGGEA:10 a=c4iJmxt-oRkA:10
 a=IkcTkHD0fZMA:10 a=3-ypyTq862YA:10 a=CkcOa_KSredVPgaKXFsA:9
 a=QEXdDO2ut3YA:10 a=IeVV3oy9AQTmNaZTXIJc:22 a=HH7FIXwXL_sUf1zzYxQd:22
Date: Thu, 23 Aug 2018 11:00:14 -0600 (MDT)
From: Mark Shuttleworth <ms@telus.net>
To: Anon Nymous <anonymous@gmail.com>
Cc: anon <anon@linux.com>
Message-ID: <1128236357.158124045.1535043614388.JavaMail.zimbra@mailid.telus.net>
Subject: 
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Originating-IP: [64.141.83.200]
X-Mailer: Zimbra 8.6.0_GA_1211 (ZimbraWebClient - GC68 (Win)/8.6.0_GA_1211)
Thread-Topic: 
Thread-Index: 4C/VEhjjLopwgDRppzCAI1WxFuTADQ==
X-CMAE-Envelope: MS4wfF577AQm5rPY75XDCo9d38reUiFqLFb/V9KgB3keLWlmmFpw2co7BOzQYtp5JuUmW5KgSZEkkAoLx3Kajb2rnH/ukB+ZyaxSNRovQpQtIdvCEc64bWTn
 QPxxSAPPTke/wftwqJmPm+qEqdkT/YAKDNLQGfl+1L/ecGDVwYnEYCWk1ufP241E4p2K5K7UVrE6zjBD/pQUaVfsYJC8S/H69RoTieoorspDGPT2a+nTSJtK



HI Anon
How are you doing?

I am at the Ubuntu library today.

When all I want is:

HI Anon
How are you doing?

I am at the Ubuntu library today.

I have tried looking at mutt, mail, mailx, but I can't find a way to just output to commandline. Opening a TUI also will not work, because I need to concatenate the messages of ~100 emails.

Regarding munpack -t foobar.eml

Did not find anything to unpack from foobar.eml

Thanks.

pLumo avatar
in flag
you can install `mpack`, then run `munpack -t foobar.eml` and `cat part1`.
uz flag
Jos
I believe the headers are separated from the mail body simply by two newline characters. You could write a script that discards everything before the `\n\n` pattern. However, you would still need to deal with HTML mail.
cn flag
@pLumo Unfortunately that does not work. It gives an error: `Did not find anything to unpack from foobar.eml`.
muru avatar
us flag
Maybe you can try a Python library like https://eml-parser.readthedocs.io/en/latest/
pLumo avatar
in flag
I think your .eml file is not valid. I tried with something exported from Thunderbird and it worked perfectly. With your .eml from your Q I get the same error.
cn flag
@pLumo These too were exported from Thunderbird. Its all right though, I ended up printing the emails as PDF's instead, and concatenated them under libreoffice draw. I also made an app for regex parsing, but I did not end up using it because the parsing becomes complex when dealing with multipart emails.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.