Filtering Outgoing mail - Was: [OT - Renaming Attachments]

2015-02-03 Thread Jeremy Bowen
On Tue, 3 Feb 2015 17:06:14 +1300
Jeremy Bowen  wrote:
> From here it looks like I need to initially  add the following lines
> to master.cf:
> filterunix  -   n   n   -   10  pipe
> flags=Rq user=filter null_sender=
> argv=/usr/local/bin/myscript -f ${sender} -- ${recipient}

I've knocked up a quick-and-dirty solution in the interim but I would
like to improve on this.

I've added the above filter section and replaced the previous content
filter with "-o content_filter=filter:dummy" to my submission service in
master.cf
Outgoing mail is now being processed by my shell script and email is
being sent OK.

However, in implementing this, I've lost the DK signing ability
and I'm also concerned at scalability & performance as alluded to in the
FILTER_README. Also, ALL outgoing email is processed by my script
whether it needs to be or not.

I would really value some recommendations on how to improve this.
Thanks.


Re: OT - Renaming Attachments

2015-02-02 Thread Jeremy Bowen
On Tue, 3 Feb 2015 11:21:17 +1300
Jeremy Bowen  wrote:
> I think I can do what I need to accomplish more accurately &
> efficiently with sed and procmail. I'm just not quite sure how I
> would go about configuring postfix to make this operate on outgoing
> mail. Any advice ?

OK, I've started with the FILTER_README and, using the "Simple
Content Filter" example, have come up with a simple shell script which
modifies the message the way I need it.
I've tested this with:
% /usr/local/bin/myscript -f sender -- recipient... 

Re: OT - Renaming Attachments

2015-02-02 Thread Jeremy Bowen
On Mon, 02 Feb 2015 14:42:47 -0600
Noel Jones  wrote:

> On 2/2/2015 2:28 PM, Jeremy Bowen wrote:
> > I would like to try to intercept certain outgoing emails which have
> > an attachment matching a particular set of criteria and then,
> > on-the-fly, rename the attachment (or extract, rename and re-attach
> > it). Maybe via a content filter - amavis or procmail ???

> The 'altermime' filter is often recommended for this.  Amavisd-new
> has some hooks for using altermime built in.  Be aware that
> altermime does not seem to be an active project, the last program
> update was several years ago.
> 
> Alternately, there are numerous perl MIME modules available that can
> be cobbled together if you can do some programming.

Thanks for that. I've just tried altermime but it appears that it only
operates on the message header and not the MIME headers in the body.
I played around modifying altermime to scan the body too but I think I'm
getting into the "thar be dragons" territory with that approach.

I think I can do what I need to accomplish more accurately & efficiently
with sed and procmail. I'm just not quite sure how I would go about
configuring postfix to make this operate on outgoing mail. Any advice ?


Re: OT - Renaming Attachments

2015-02-02 Thread Noel Jones
On 2/2/2015 2:28 PM, Jeremy Bowen wrote:
> This one is a bit off-topic however I'm hoping that someone has come
> across something similar and can point me in the right direction. 
> 
> I would like to try to intercept certain outgoing emails which have an
> attachment matching a particular set of criteria and then, on-the-fly,
> rename the attachment (or extract, rename and re-attach it). Maybe
> via a content filter - amavis or procmail ???
> 
> These emails have a MIME "Content-Type: application/pdf;" header but
> the filename does not have a .pdf extension, which confuses the bulk of
> Windows email clients.
> 
> I vaguely remember doing something similar with tnef/winmail.dat files
> over a decade ago but I can't find any details now (and I may be
> completely off base). Thanks in advance.
> 

The 'altermime' filter is often recommended for this.  Amavisd-new
has some hooks for using altermime built in.  Be aware that
altermime does not seem to be an active project, the last program
update was several years ago.

Alternately, there are numerous perl MIME modules available that can
be cobbled together if you can do some programming.



  -- Noel Jones




OT - Renaming Attachments

2015-02-02 Thread Jeremy Bowen
This one is a bit off-topic however I'm hoping that someone has come
across something similar and can point me in the right direction. 

I would like to try to intercept certain outgoing emails which have an
attachment matching a particular set of criteria and then, on-the-fly,
rename the attachment (or extract, rename and re-attach it). Maybe
via a content filter - amavis or procmail ???

These emails have a MIME "Content-Type: application/pdf;" header but
the filename does not have a .pdf extension, which confuses the bulk of
Windows email clients.

I vaguely remember doing something similar with tnef/winmail.dat files
over a decade ago but I can't find any details now (and I may be
completely off base). Thanks in advance.