Weblog entry #93 for dkg
It reads a message from stdin, and prints a visualisation of its structure, like this:
0 dkg@alice:~$ printmimestructure < 'Maildir/cur/1269025522.M338697P12023.monkey,S=6459,W=6963:2,Sa' └┬╴multipart/signed 6546 bytes ├─╴text/plain inline 895 bytes └─╴application/pgp-signature inline [signature.asc] 836 bytes 0 dkg@alice:~$You can fetch it with git if you like:
git clone git://lair.fifthhorseman.net/~dkg/printmimestructureIt feels silly to treat this ~30 line script as its own project, but i don't know of another simple tool that does this. If you know of one, or of something similar, i'd love to hear about it in the comments (or by sending me e-mail if you prefer).
If it's useful for others, I'd be happy to contribute printmimestructure to a project of like-minded tools. Does such a project exist? Or if people think it would be handy to have in debian, i can also package it up, though that feels like it might be overkill.
and oh yeah, as always: bug reports, suggestions, complaints, and patches are welcome :)
Comments on this Entry
[ Send Message | View dkg's Scratchpad | View Weblogs ]
And wouldn't i need to set up and configure mutt to do that? last time i tried to configure mutt, it was a daylong project and i felt i'd only scratched the surface. Hopefully it's gotten better since then, though :)
Thanks for the suggestion!
[ Parent | Reply to this comment ]
I 1 <no description> [multipa/signed, 7bit, 3.3K]
I 2 --><no description> [text/plain, quoted, iso-8859-1, 2.0K]
A 3 -->OpenPGP digital signature [applica/pgp-signat, 7bit, 0.9K]
I 4 <no description> [text/plain, 7bit, us-ascii, 0.2K]
However, I normally use something like
#!/usr/bin/perl
use strict;
use warnings;
use Email::MIME;
my $email = join('', <STDIN>);
my $mime = Email::MIME->new($email);
print $mime->debug_structure;
when I need to access the MIME structure ...
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
package nmh has mhlist ...
mhlist -f ~/spool/p1
msg part type/subtype size description
0 multipart/mixed 149K
1 multipart/alternative 10K
1.1 text/html 8046
1.2 text/plain 2052
2 application/octet-stream 102K 16_November.pdf
3 text/plain 165
[ Parent | Reply to this comment ]
[ Send Message | View dkg's Scratchpad | View Weblogs ]
0 dkg@alice:/tmp$ /usr/bin/mh/mhlist -f - < /tmp/Ticket-6787.eml mhlist: Doesn't look like nmh is installed. Run install-mh to do so. 1 dkg@alice:/tmp$and install-mh isn't in my $PATH either. Reading install-mh(8) makes it sound like i have to configure a mail user agent just to use this tool, which goes back to my earlier objection about mutt. :(
These seem like silly hoops to have to jump through for a program that just needs to read from stdin and write to stdout.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]