Re: [Evolution] automagic mail forward -- a solution



It might be easier just requesting these new things in a bug report. 
Dunno if they're there already.

The code required for a forward-to and shell-with-stdin thing is
probably not too much, particularly with some new process code we have. 
Would probably have to wait till after 1.4 though.

On Thu, 2003-03-06 at 08:50, guenther wrote:
cheers( folks );

As this question came up several times the last days on these lists,
here is a practical solution.

When thinking about another problem on the evolution mailing list, I
found a way, how to do that. I will discuss the whole problem in this
mail -- feel free to skip to the code. ;-)

Any suggestions on improving this approach is welcome.


** Filter and Actions

What we want is forwarding mail by Filter. The problem is, there is no
'forward' Action and there is no 'pipe message to shell command' Action
too.

We can circumvent that problem with a little bit of programmers logic,
as there is a 'pipe to shell command' Criterion. The logic is, that all
Criteria are evaluated in the defined order. Hitting the first failing
Criterion will prevent all other Criteria from being evaluated.

So we can define all Criteria we wanna match to forward a mail and add a
last Criteria, that actually will forward the mail. We are only
interested in the side-effects, thus we don't care about the return
code.


** Setting up the Filter

Create a incoming Filter like this example:

 Execute actions:
  'if all criteria are met'

 Criterion:
  'Subject' 'starts with' '[forward]'
  # define as much, as you like

 Criterion:
  'pipe message to shell command' 'my-forward-script.sh' 'returns' '0'

 Action:
  'stop processing'

The pipe Criterion (actually a command) will only be executed, when all
leading Criteria are met. We really don't care about the Action...


** Fowarding Mail by Shell Script

Instead of the 'my-forward-script.sh' we can use a one line shell
command:

 formail -I 'To: user forward host' -I Cc: | sendmail -t

I just could not test that, as my sendmail (postfix actual)
configuration really is broken...

What does it do? formail rewrites the header, to avoid bugging others.
All To: and Cc: headers are deleted and we set a new recipient. The -t
option tells sendmail to use the recipients in the mail header.


To test that beforehand, you can use something like the following
command, which will append all mails to a file instead of sending them.

 formail -I 'To: user forward host' -I Cc: >> /home/user/tmp/forward


** Prerequisites, more Info

You will need formail and an MTA like sendmail installed (and
configured...)

man formail, man sendmail ;-)


btw: I still prefer procmail for that -- if you have the possibility to
use it.


I hope, that will get you working. Please drop me a note and report
improvements here, if you actually use it...

...guenther


-- 
char *t="\10pse\0r\0dtu\0  ghno\x4e\xc8\x79\xf4\xab\x51\x8a\x10\xf4\xf4\xc4";
main(){ char h,m=h=*t++,*x=t+2*h,c,i,l=*x,s=0; for (i=0;i<l;i++){ i%8? c<<=1:
(c=*++x); c&128 && (s+=h); if (!(h>>=1)||!t[s+h]){ putchar(t[s]);h=m;s=0; }}}

_______________________________________________
evolution maillist  -  evolution lists ximian com
http://lists.ximian.com/mailman/listinfo/evolution




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]