#!/usr/local/bin/perl -w use Data::Dumper; use Date::Format; use Mail::Box; use Mail::Box::Manager; use MIME::Words qw(:all); use constant TIMEZONE => 'MEST'; #Set your mailbox's FULL path within the "" right here $mbox = "/var/mail/codexx"; #Set the amount of emails you wish to read. If you set this # value to 5, the script will try to read the 5 most CURRENT # messages from your INBOX. # I advise you NOT to use more than 25 here, since parsing a huge # inbox can take a very long time! my $limit = 5; #STOPSTOPSTOPSTOPSTOPSTOP #if the maiblox file is not existant return ENOENT if (!-e $mbox) { exit 2; } #if we do not have access to read from that mailbox return EACCESS if (!-r $mbox) { exit 13; } my $mgr = Mail::Box::Manager->new; my $folder = $mgr->open( folder => $mbox, ) or exit 61; #if we cannot open the mailbox we will not be able to #return any data, so exit with ENODATA $mgr->registerType( mbox => 'Mail::Box::Mbox' ); my $number_of_emails = $folder->messages; if ($number_of_emails < $limit) { $boundary = ($number_of_emails+10)-$number_of_emails; } else { $boundary = 0; } print "\n<\!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\" \"http://my.netscape.com/publish/formats/rss-0.91.dtd\">\n\n"; print " RSS file \nhttp://www.kde.org\nThis is an automatically generated file using the NNTP to RSS generator for Knewsticker.\nen-us\n"; print "\n"; my (@from, @time, @subject, @size, @from_email); foreach ($boundary .. $number_of_emails - 1) { chomp($subject[$_] = $folder->message($_)->head->get('subject')); # $size[$_] = $folder->message($_)->size; # $size[$_] = $size[$_] / 1024; # $size[$_] = substr($size[$_],0,5) ."kb"; chomp($from[$_] = $folder->message($_)->head->get('from')); $time[$_] = time2str('%a %b %e', $folder->message($_)->timestamp, TIMEZONE); ($from_email[$_]) = ($from[$_] =~ /([^<]*)/); ($from[$_]) = ($from[$_] =~ /<([^>]*?)>/); defined($from_email[$_]) or $from_email[$_] = $from[$_]; for ($subject[$_], $from[$_]) { s{&}{&}g; s{\(}{(}g; s{\)}{)}g; #s{@}{@}g; s{<}{<}g; s{>}{>}g; }; for ($subject[$_]) { decode_mimewords($_); } print< Mail from: $from_email[$_] concerning $subject[$_] sent at $time[$_] mailto://$from[$_] EOT }; print "\n\n";