This file is indexed.

/usr/bin/topica2mail is in libwww-topica-perl 0.6-4.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/perl -w

eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
    if 0; # not running under some shell

use strict; 

use Time::Piece;
use Date::Parse;

use WWW::Topica;
use Email::Simple; 
use Email::LocalDelivery;

=pod

=head1 NAME

topica2mail - convert a Topica mailing list into a mail box

=head1 USAGE

    topica2mail <list-id> <mailbox> [login] [password] [ -d ] [ -l ] [ -s <start> ] [ -e <end> ]

=head1 OPTIONS

=head2 list-id

The name of the list

=head2 mailbox

The mailbox you want to deliver the mail into. 
Will automatically prepend the year and the month so

    foo

will turn into

    foo-2004-10

etc etc

=head2 login

Your login email address. 

If you don't pass in your login and password you may not be able to read some lists.

=head2 password

Your password

If you don't pass in your login and password you may not be able to read some lists.

=head2 -d

Debug - print out debug messages where appropriate

=head2 -l 

Local - use the local test files (for testing, obviously)

=head2 -s <start>

Which mail offset to start from

=head2 -e <end>

Which mail offset to end on

=head1 AUTHOR

Simon Wistow <simon@thegestalt.org>

=head1 COPYRIGHT

Copyright (c), 2004 - Simon Wistow

Distributed under the same terms as Perl itself

=cut 


my $email;
my $pass;
my $list  = shift || die "You must pass a list name\n";
my $out   = shift || die "You must pass a mailbox\n";

if (@ARGV && $ARGV[0] !~ /^-/ && $ARGV[1] !~ /^-/) {
    $email = shift;
    $pass  = shift;
}

my %opts = (
                list     => $list,
                email    => $email,
                password => $pass,
                debug    => 0,
                local    => 0,
            );

while (my $arg = shift @ARGV) {
    if ($arg eq '-d') {
        $opts{debug} = 1;
    } elsif ($arg eq '-l') {
        $opts{local} = 1;
    } elsif    ($arg eq '-s') {
        $opts{first} = shift;
    } elsif    ($arg eq '-e') {
        $opts{last} = shift;
    } else {
        die "Confused by $arg - bailing out\n";
    }


}



my $topica = WWW::Topica->new(%opts);

print "\n\n" if $opts{debug};

my $counter  = 1;
while (my $rfc822 = $topica->mail) {
    
    my $mail = Email::Simple->new($rfc822);

    my $date = $mail->header("date");
    my $time = str2time($date);
    my $tp   = Time::Piece->new($time);

    my $mbox = sprintf "%s-%.4d-%.2d", $out, $tp->year, $tp->mon;

    print     "\t\t". $counter++.") ".
               $mail->header("from")." - ". 
               $mail->header("subject")." - ". 
               $mail->header("date")." to $mbox\n\n";

    Email::LocalDelivery->deliver($mail->as_string, $mbox) 
        || die "Couldn't deliver mail to $mbox\n";

}