Best wau to rewrite subject line based on FROM address...

Has anyone had experience with re-writing the subject line of a message based on the FROM address? I am trying to accomplish the following:

1) if the FROM address of a message is "something@sompleace.com" and SUBJECT of message is "some special subject" then:

2) rewrite from address to be "Some.new@from.com" and rewrite subject to be "A new subject here".

I've done alot of reading in the docs and on the forums and have come to the following conclusions:

1) I can use sieve filters to filter on the above criteria, but the best i can for processing would be to forward them to some special mailbox, where I would need a program that would actualy read them and perform the mangling, and then resend them to the original recipient

2)Maybe use a conversion channel, passign in the subject via environment variables. I would need to write a shell script that would copy the message, mangle it, and then pass it back to the MTA for delivery?

3) maybe install spam assasin - it seems like it adds extensions to the seive filters that allow mangling of the subject line, but the examples I have seen seem limited to adding a special "tag" to the subject, not replacing it in its entirety.

Can anyone advise me of the right approach to follow? Or let me know that I am smoking crack and there is some other better way to accomplish what I want? For example, is it possible to use procmail to do this?

thanks in advance!

-mike cirioli

[1491 byte] By [mike_ciriolia] at [2007-11-26 16:36:15]
# 1

> Has anyone had experience with re-writing the subject

> line of a message based on the FROM address? I am

> trying to accomplish the following:

>

> 1) if the FROM address of a message is

> "something@sompleace.com" and SUBJECT of message is

> "some special subject" then:

> 2) rewrite from address to be "Some.new@from.com" and

> rewrite subject to be "A new subject here".

>

> I've done alot of reading in the docs and on the

> forums and have come to the following conclusions:

>

> 1) I can use sieve filters to filter on the above

> criteria, but the best i can for processing would be

> to forward them to some special mailbox, where I

> would need a program that would actualy read them and

> perform the mangling, and then resend them to the

> original recipient

Untrue.Sieve can replace a header line, if you want.

>

> 2)Maybe use a conversion channel, passign in the

> subject via environment variables. I would need to

> write a shell script that would copy the message,

> mangle it, and then pass it back to the MTA for

> delivery?

Sounds like a much harder way to go. Also more costly in terms of performance.

>

> 3) maybe install spam assasin - it seems like it adds

> extensions to the seive filters that allow mangling

> of the subject line, but the examples I have seen

> seem limited to adding a special "tag" to the

> subject, not replacing it in its entirety.

While I personally use SpamAssassin, it adds no sieve functions at all. It just gives a "spam score" back to the MTA. Header rewriting is handled by Sieve.

>

> Can anyone advise me of the right approach to follow?

> Or let me know that I am smoking crack and there is

> some other better way to accomplish what I want? For

> example, is it possible to use procmail to do this?

I've never touched procmail. I suspect sieve is the way to go.

jay

>

> thanks in advance!

> -mike cirioli

jay_plesseta at 2007-7-8 23:01:11 > top of Java-index,E-Mail, Calendar, & Collaboration,Sun Java System Messaging Server...
# 2

Thanks for the information. Would it be possible to provide an example of a sieve rule that implements replacing the Subject header? I read through the RFC for the sieve language and didn't catch anything along those lines. Also, where should I look to find a definitive list of the supported sieve command actions at are availble in MessageCenter?

Thanks so much!!

-mike

mike_ciriolia at 2007-7-8 23:01:11 > top of Java-index,E-Mail, Calendar, & Collaboration,Sun Java System Messaging Server...
# 3
We claim to implement pretty much all of it. Alas, I don;t personally do sieve. Shane might be able to weigh in, though.
jay_plesseta at 2007-7-8 23:01:11 > top of Java-index,E-Mail, Calendar, & Collaboration,Sun Java System Messaging Server...
# 4

Hi,

I played around a bit with sieve filters to rewrite the subject. The good-news is that you can indeed replace the subject (as per example below), the bad-news is that editheaders isn't supported in 6.2 (but is in 6.3).

The example below is based on two draft RFC's:

http://www.ietf.org/internet-drafts/draft-ietf-sieve-variables-08.txt

http://www.ietf.org/internet-drafts/draft-ietf-sieve-editheader-07.txt

<begin script>

require ["fileinto", "variables", "editheader"];

# Imagine the header

# Subject: [acme-users] [fwd] version 1.0 is out

if header :matches "Subject" "[*] *" {

# ${1} will hold "acme-users",

# ${2} will hold "[fwd] version 1.0 is out"

fileinto "INBOX.lists.${1}"; stop;

}

if header :matches "Subject" "*" {

# ${1} will hold the Subject

# Adds square braces around the subject

deleteheader "Subject";

addheader "Subject: [${1}]"; keep;

}

<end script>

You could in theory extend this script to use the value of the 'from' address or the subject to say, append the senders address to the subject line (using variables) or fileinto a folder based on the senders email address etc.

Regards,

Shane.

shane_hjortha at 2007-7-8 23:01:11 > top of Java-index,E-Mail, Calendar, & Collaboration,Sun Java System Messaging Server...