On 10/28/2014 7:10 PM, David F. Skoll wrote:
On Wed, 29 Oct 2014 01:31:51 +0100
Reindl Harald<h.rei...@thelounge.net>  wrote:

frankly in times of LMTP and Sieve there is hardly a need to use
procmail - it is used because "i know it and it just works" - so why
should somebody step in and maintain it while nobody is forced to use
it

I use Email::Filter, not procmail, but tell me: Can LMTP and Sieve do
the following?

1) Cc: mail containing a specific header to a certain address, but only
between 08:00-09:00 or 17:00-21:00.


Yes - it would be ugly but you could do this from cron.  Just make up 2
procmail recipes and have the cron job copy over the one on tap.

2) Archive mail in a folder called Received-Archive/YYYY-MM.


There's a milter for that.  (I use Sendmail myself)

3) Take mail to a specific address, shorten it by replacing things
like "four" with "4", "this" with "dis", etc. and send as much of the
result as possible as a 140-character SMS message?  Oh, and only do
this if the support calendar says that I am on the support pager that
week.


Probably - but I wouldn't want to write it either in Perl or
Procmail, nor would I want to read the result!  So what happens if
the mailserver that your running the SMS text email through bites
the dust?

4) Take the voicemail notifications produced by our Asterisk
software and replace the giant .WAV attachment with a much
smaller .MP3 equivalent.



This is what I use for that (no Procmail in this)

tedm-voicemail: "| /usr/local/bin/wavmail-to-mp3mail.pl | /usr/sbin/sendmail -i -f v...@example.com t...@example.com"

#!/usr/bin/perl
#
use MIME::Parser;
use IO::File;

$p = new MIME::Parser;
$p->output_to_core(1);
$e = $p->parse(\*STDIN);
$f = "/tmp/$$";

#
# If running on FBSD then this might be simpler
# open(PIPE, "|/usr/local/bin/ffmpeg -i - -f mp3 $f");
#
# SOX can read the compressed ADPCM since it uses different sound libraries but it cannot change # the bitrate, and the bitrate that the Panasonic puts out is unusual - while it can be put into # an .mp3 by sox, nothing can read it. Instead we convert the wav to regular PCM which lame
#  can understand
#
open(PIPE, "|/usr/local/bin/sox -t wav - -s -t wav - | /usr/local/bin/lame --preset phone -v -q 0 -V 9 --quiet - $f");
print PIPE $e->parts(1)->bodyhandle->as_string;
close PIPE;

if( open(PIPE,"< :bytes",$f) ) {
if( $fh = $e->parts(1)->bodyhandle->open(w) ) {
my $buffer;
while( read(PIPE, $buffer, 10240) > 0 ) ### read chunks of 10KB at a time
{
$fh->print($buffer);
}
$fh->close;
}
close PIPE;
}

$e->parts(1)->head->replace("Content-type","audio/mp3");
$e->parts(1)->head->mime_attr("content-type.name"=>"voice-mail.mp3");

$e->parts(1)->head->replace("Content-Disposition","attachment");
$e->parts(1)->head->mime_attr("content-disposition.filename"=>"voice-mail.mp3");

$e->parts(0)->bodyhandle->as_string =~ m/\((\d+)\)/m;

$e->sync_headers(Length=>"COMPUTE");

$e->print;

unlink($f);
smtp#

I'd be interested in seeing how you do it with your filter.

Ted

These are all real-world requirements that my filter fulfills.  And it
does most of them without forking external processes.  (Item 3 actually consults
a calendar program to see who's on support, but the rest are all handled
in-process.)

Regards,

David.

Reply via email to