Combine many email files with unix utils

I would like to know if there is an easy way to print multiple emails (around 200) so that they continue instead of printing one per page. I've tried with thunderbird and evolution and it doesn't seem possible. Can concatenating individual zip files work or are there other unix utilities that can do this? Is the wuld sed or awk method suitable for this?

+1


source to share


4 answers


Why don't you put all the data from the letters into one text file and print that file.

This can be done as follows:

cat *.eml > file.txt

      



Or print it directly with

cat *.eml | lpr

      

+3


source


Perl makes it easy to work with Email :: Abstract . Give the following script (maildump) a list of emails to dump and then stream the whole thing to lpr ...

maildump m1 m2 m3 m4 | LPR



#!/usr/bin/perl

use Email::Abstract;

while ($mfile = shift @ARGV)
{
    open(DATA, "&lt$mfile") || die "unable to open $mfile";

    my $message = do { local $/; <DATA>; };

    my $email = Email::Abstract->new($message);

    my $subject = $email->get_header("Subject");
    my $from = $email->get_header("From");
    my $date = $email->get_header("Date");
    my $body = $email->get_body;

    print "SUBJECT: $subject\nFROM: $from\nDATE: $date\n\n$body\n\n";
    print "-" x 65, "\n" if $#ARGV &gt 0;
}

      

+1


source


I can say for sure about * n * x, but if it is possible to define a printer that only outputs text and outputs it to a text file, you can print your batch to that printer and remove the -feeds form from the resulting text file.

I used a similar technique on Windows: create a new printer using the Generic / Text-Only driver and specify the output to be a text file. Then print everything, specify the location of the output file in the print dialog, and then clear the result when printing. In the meantime, there is no need to worry about it.

0


source


If you want to filter emails, I suggest finding where the data is stored and scripting solutions at that level.

In my Windows window, Thunderbird keeps my inbox in a fairly large-ish file at

C: \ Documents and Settings \ Bruce Axtens \ Application Data \ Thunderbird \ Profiles \ x5j9chtd.default \ Mail \ Local Folders \ Inbox

I don't know where * n * x stores yours: maybe in a hidden folder in the root directory. For example.

/home/josh/.thunderbird

Analyzing raw email data is not for the faint of heart (although Wikipedia has a good email article to get you started in the right direction.)

For the rest of us (myself included), there are many scripting resources to perform the hack for you while you build your solution. If you find this as a good place to start for Perl. Others may offer libraries for other languages.

0


source







All Articles