[Evolution] Re: mail forwarding filter
Not Zed
notzed@ximian.com
Tue, 01 Mar 2005 10:30:41 +0800
--=-4QWFtPHpAJzQTxu6XKXW
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
On Mon, 2005-02-28 at 08:51 -0500, Gangalino wrote:
> On Mon, 2005-28-02 at 14:24 +0800, Not Zed wrote:
> >
> > Well, strictly speaking, it is not entirely incorrect.
> >
> > You can still use filters to do that, by using the filers to run a
> > script which does the forwarding, e.g. via the 'mail' command.
> >
> > On Sun, 2005-02-27 at 23:48 -0500, Gangalino wrote:
> > > You think I would lie about something like this?
> > > Check your help- 3.6 Create Rules to Automatically Or Organize Mail:
> > > "For example, your filters could put copies of one message into multiple
> > > folders, or keep one copy and send one to another person."
> > >
> > > Which would be a perfectly normal use of a filter.
> > > YOUR bug link, however, is untrue. :)
> >
> Can you provide me with an example of such a script. Unfortunately, I'm
> on this GARBARGE BELL/SYMPATICO ISp that filters out any outgoing mail,
> but I am on a linux machine w/ Postfix/Sendmail, and the address I want
> to forward to mostly is an alias local to my machine.
At the simplest form, for sendmail or postfix, you add an action:
"Pipe to Program"
and use
/usr/sbin/sendmail -f yourreply@address the.target@address
This will effectively "redirect" or "bounce" the message to
"the.target@address", and send any errors to "yourreply@address".
Then you could add other actions to e.g. mark the mail as read or
whatever.
If you want to form an attachment of the message it gets a bit trickier,
and you need a script. I've attached an example script - it is a little
more sophisticated than the trivial-case, as it extracts (multiline)
subject to form a destination subject. It could be changed to take the
target address from the command line or calculate it from the message.
--- begin script ---
#!/bin/sh
# forwards an rfc822 message from stdin to "to" coming from "from" as a
mime attachment
from="not zed <notzed@novell.com>"
errors="notzed@novell.com"
to="mike <notzed@ximian.com>"
msg=~/.forward.$$
date=`date --rfc-2822`
# save message
cat - >$msg
# generate forwarded subject
subject=`cat $msg | sed -e "/^$/ q" -e "/^Subject:/ s/Subject:/Subject:
Fw:/" -e "/^Subject:/,/^[\t ]/ p" -e "d" -e "/^$/ q"`
# build/send message
( echo "From: $from"
echo "To: $to"
echo "$subject"
echo "Date: $date"
echo "Mime-Version: 1.0"
echo "Content-Type: message/rfc822"
echo ""
cat $msg ) | /usr/sbin/sendmail -f $errors $to
rm $msg
--=-4QWFtPHpAJzQTxu6XKXW
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.5.5">
</HEAD>
<BODY>
On Mon, 2005-02-28 at 08:51 -0500, Gangalino wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">On Mon, 2005-28-02 at 14:24 +0800, Not Zed wrote:</FONT>
<FONT COLOR="#000000">> </FONT>
<FONT COLOR="#000000">> Well, strictly speaking, it is not entirely incorrect.</FONT>
<FONT COLOR="#000000">> </FONT>
<FONT COLOR="#000000">> You can still use filters to do that, by using the filers to run a</FONT>
<FONT COLOR="#000000">> script which does the forwarding, e.g. via the 'mail' command.</FONT>
<FONT COLOR="#000000">> </FONT>
<FONT COLOR="#000000">> On Sun, 2005-02-27 at 23:48 -0500, Gangalino wrote: </FONT>
<FONT COLOR="#000000">> > You think I would lie about something like this?</FONT>
<FONT COLOR="#000000">> > Check your help- 3.6 Create Rules to Automatically Or Organize Mail:</FONT>
<FONT COLOR="#000000">> > "For example, your filters could put copies of one message into multiple</FONT>
<FONT COLOR="#000000">> > folders, or keep one copy and send one to another person."</FONT>
<FONT COLOR="#000000">> > </FONT>
<FONT COLOR="#000000">> > Which would be a perfectly normal use of a filter.</FONT>
<FONT COLOR="#000000">> > YOUR bug link, however, is untrue. :)</FONT>
<FONT COLOR="#000000">> </FONT>
<FONT COLOR="#000000">Can you provide me with an example of such a script. Unfortunately, I'm</FONT>
<FONT COLOR="#000000">on this GARBARGE BELL/SYMPATICO ISp that filters out any outgoing mail,</FONT>
<FONT COLOR="#000000">but I am on a linux machine w/ Postfix/Sendmail, and the address I want</FONT>
<FONT COLOR="#000000">to forward to mostly is an alias local to my machine.</FONT>
</PRE>
</BLOCKQUOTE>
<PRE>
</PRE>
At the simplest form, for sendmail or postfix, you add an action:<BR>
<BR>
"Pipe to Program"<BR>
and use<BR>
/usr/sbin/sendmail -f <A HREF="mailto:yourreply@address">yourreply@address</A> <A HREF="mailto:the.target@address">the.target@address</A><BR>
<BR>
This will effectively "redirect" or "bounce" the message to "<A HREF="mailto:the.target@address">the.target@address</A>", and send any errors to "<A HREF="mailto:yourreply@address">yourreply@address</A>".<BR>
<BR>
Then you could add other actions to e.g. mark the mail as read or whatever.<BR>
<BR>
If you want to form an attachment of the message it gets a bit trickier, and you need a script. I've attached an example script - it is a little more sophisticated than the trivial-case, as it extracts (multiline) subject to form a destination subject. It could be changed to take the target address from the command line or calculate it from the message.<BR>
<BR>
--- begin script ---<BR>
#!/bin/sh<BR>
<BR>
# forwards an rfc822 message from stdin to "to" coming from "from" as a mime attachment<BR>
<BR>
from="not zed <<A HREF="mailto:notzed@novell.com">notzed@novell.com</A>>"<BR>
errors="<A HREF="mailto:notzed@novell.com">notzed@novell.com</A>"<BR>
to="mike <<A HREF="mailto:notzed@ximian.com">notzed@ximian.com</A>>"<BR>
<BR>
msg=~/.forward.$$<BR>
date=`date --rfc-2822`<BR>
<BR>
# save message<BR>
cat - >$msg<BR>
<BR>
# generate forwarded subject<BR>
subject=`cat $msg | sed -e "/^$/ q" -e "/^Subject:/ s/Subject:/Subject: Fw:/" -e "/^Subject:/,/^[\t ]/ p" -e "d" -e "/^$/ q"`<BR>
<BR>
# build/send message<BR>
( echo "From: $from"<BR>
echo "To: $to"<BR>
echo "$subject"<BR>
echo "Date: $date"<BR>
echo "Mime-Version: 1.0"<BR>
echo "Content-Type: message/rfc822"<BR>
echo ""<BR>
cat $msg ) | /usr/sbin/sendmail -f $errors $to<BR>
<BR>
rm $msg<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
</BODY>
</HTML>
--=-4QWFtPHpAJzQTxu6XKXW--