Mike Cisar wrote: > Hi all, > > Running Sendmail/Amavis/Spamassassin/Dovecot on a couple of servers. About > 50% of the users prefer to be spoon-fed their SPAM in their inbox, for the > other 50% or so we've set up to sort their SPAM into an IMAP spam folder > using plussed addressing. > > A number of users still use POP to access their mail and as such require a > "reminder" to log in to their webmail once in a while to clean up their spam > folder. > > What I'm looking for is a way (script that I can run in a daily cron) to > scan each of these user's spam folder and produce a quick summary of the > mail therein (from, to, subject) and email them the result. If it matters, > we will be migrating to likely a maildir format when we migrate to a new > server in the spring, but for now the IMAP folders are UW-mbox format (or is > that mbx, I can never remember which is which :-) > > Can anyone recommend a script that could accomplish what I'm looking to do? >
you could start with formail -l "" -ds < mboxfile this will print things like this: From [EMAIL PROTECTED] Wed Jan 30 16:45:12 2008 Subject: =?utf-8?B?TW9iaWxlIFdvcmxkIENvbmdyZXNz?= =?utf-8?B?IDogV2 Folder: 7052 if you want to chose the headers, you can try something like formail -cX "" -ds < mboxfile | \ egrep "^(From|To|Cc|Subject|Date)" | \ sed "s/^From .*//" Note that headers may be mime encoded (subject shown above), in which case they are not "readable". you will need to decode them (if they are to be sent via email, then don't forget to encode the body!). or you could try something like this if the mbox is not too large: #!/usr/bin/perl use Mail::MboxParser; use strict; my $mbox_file = $ARGV[0]; #headers to print my @print_headers = ("From", "Date", "Subject", "Content-Length", "X-Spam-Score"); my $parseropts = { enable_cache => 1, enable_grep => 1, cache_file_name => '/tmp/mbox_cache', }; my $mb = Mail::MboxParser->new($mbox_file, decode => 'HEADER', parseropts => $parseropts); while (my $msg = $mb->next_message) { print "\n"; foreach my $header (@print_headers) { print "$header: " . $msg->header->{"\L$header"} . "\n"; } } ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ AMaViS-user mailing list AMaViS-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amavis-user AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3 AMaViS-HowTos:http://www.amavis.org/howto/