Mail::Procmail |
|||||
|
|||||
|
|
||||
Procmail-like facility for creating easy mail filtersprocmail is a great mail filter program, but it has weird recipe format. It's pattern matching capabilities are basic and often insufficient. I wanted something flexible whereby I could filter my mail using the power of Perl. I've been considering to write a procmail replacement in Perl for a
while, but it was Simon Cozen's I first started using Simon's great module, and then decided to write my own since I liked certain things to be done differently. And I couldn't wait for his updates. Currently, Simon and I are in the process of considering to port my enhancements to his code as well.
For example, a simple filter that copies incoming mail regarding a specific subject to a separate mailbox, while also sending it to a friend: #!/usr/bin/perl -w use strict; use Mail::Procmail; pm_init(logfile=>'stderr', loglevel=>3); if ( pm_gethdr("subject") =~ /interesting topic/i ) { pm_resend("my_friend@somewhere.com", continue => 1); pm_deliver($ENV{HOME}."/Mail/interesting"); } # Default delivery. pm_deliver("/var/spool/mail/".getpwuid($>)); As can be deduced from the pm_init() call, logging will be done to standard error. If a suitable message comes along, the following information will be logged: 2000/08/08 21:23:55 Mail from John Doe The number between If the message did not have the interesting subject, the log would show: 2000/08/08 21:26:14 Mail from John Doe All headers, and the body, of the message are at your disposal, so you can use all the powers of perl pattern matching for your email filtering. Delivery routinesMost delivery routines will exit the program with status
Requirements
LicenseGPL or Artistic, whatever you prefer. Credits
|
|||||
|
|
||||
© Copyright 2003-2018 Johan Vromans. All Rights Reserved. |