Hi Jeremy,
> I was thinking of doing something similar to the above (re-encode
> mime attachments) now but I'm not sure what the best way of handling
> this is.
I'm using the following setup to modify attachments from a specific
sender only:
/etc/postfix/master.cf:
tiff2pdf unix - n n - - pipe
flags= user=nobody directory=/path/ argv=/path/tiff2pdf.pl
${nexthop} ${sender} ${recipient}
/etc/postfix/tiff2pdf:
example.com FILTER tiff2pdf:
/etc/postfix/main.cf or master.cf:
smtpd_sender_restrictions=hash:/etc/postfix/tiff2pdf
The tiff2pdf.pl file reads the message from stdin:
my $parser = new MIME::Parser;
$msg = $parser->parse(\*STDIN) or die "FaxTIFF2PDF: parse failed\n";
and then does its magic iterating through the attachments, deciding what
to do, de- and re-attaching them as needed.
Finally, it uses "use IPC::Open2;" to issue this command:
$pid = open2(\*CHLD_OUT, \*CHLD_IN, '/usr/sbin/sendmail', '-G', '-i',
'-f', "$from", "$to");
$msg->print(\*CHLD_IN);
close(\*CHLD_IN);
waitpid( $pid, 0 );
my $child_exit_status = $? >> 8;
if ($child_exit_status ne 0){ die print "Error from sendmail:
$child_exit_status"};
This may not be the most elegant way to do this, but it certainly works
very well.
Best regards,
-hannes