Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: exim: users

Rewrite FROM address

 

 

First page Previous page 1 2 Next page Last page  View All exim users RSS feed   Index | Next | Previous | View Threaded


Luke.Sheldrick at an0key

Jan 26, 2008, 9:08 AM

Post #1 of 30 (1007 views)
Permalink
Rewrite FROM address

Hello,

Another quick question, I personally utilise receipent forwarding or
whatever it is called, i.e. Luke+forumname[at]an0key.co.uk will come to
luke[at]an0key.co.uk

However to reply to groups, I have subscribed to using this method, means
the mail has to come from that address. The way I am doing it, is to setup a
new imap account in my email software. However this is getting all a bit
much :P

Is there a way to get exim to rewrite the from, if the to is a paticular
address. I.e. If a mail comes from luke[at]an0key.co.uk, destined for
user-forum[at]somesite.com, it can rewrire it to luke+somesite[at]an0key.co.uk?

I am guessing it can, but havent a clue on the config.

Cheers
--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


wbh at conducive

Jan 26, 2008, 4:56 PM

Post #2 of 30 (943 views)
Permalink
Re: Rewrite FROM address [In reply to]

Luke Sheldrick wrote:
> Hello,
>
> Another quick question, I personally utilise receipent forwarding or
> whatever it is called, i.e. Luke+forumname[at]an0key.co.uk will come to
> luke[at]an0key.co.uk
>
> However to reply to groups, I have subscribed to using this method, means
> the mail has to come from that address. The way I am doing it, is to setup a
> new imap account in my email software. However this is getting all a bit
> much :P
>
> Is there a way to get exim to rewrite the from, if the to is a paticular
> address. I.e. If a mail comes from luke[at]an0key.co.uk, destined for
> user-forum[at]somesite.com, it can rewrire it to luke+somesite[at]an0key.co.uk?
>
> I am guessing it can, but havent a clue on the config.
>
> Cheers

It can. Other have done such things in several ways, and a search of the
archives should find some examples.

But you may not need to. You mentioned using IMAP.

Member of 'many' lists, I simply use filters in the MUA to move or copy
incoming from each of many mailings lists to a folder or 'tree' of
folders for the list(s).

Any that might be needed when 'roaming' are server-side folders -
otherwise 'Local'.

With just one address, the MUA filter triggers, using this list as an
example, on:

'return path' contains 'exim-users'

= No need for a specialized addresses.

= No need to rewrite the 'From:'

HTH,

Bill


--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


Luke.Sheldrick at an0key

Jan 27, 2008, 9:33 AM

Post #3 of 30 (975 views)
Permalink
Re: Rewrite FROM address [In reply to]

On 27/01/2008 00:56, "W B Hacker" <wbh[at]conducive.org> wrote:

> Luke Sheldrick wrote:
>> Hello,
>>
>> Another quick question, I personally utilise receipent forwarding or
>> whatever it is called, i.e. Luke+forumname[at]an0key.co.uk will come to
>> luke[at]an0key.co.uk
>>
>> However to reply to groups, I have subscribed to using this method,
means
>> the mail has to come from that address. The way I am doing it, is to
setup a
>> new imap account in my email software. However this is getting all a
bit
>> much :P
>>
>> Is there a way to get exim to rewrite the from, if the to is a
paticular
>> address. I.e. If a mail comes from luke[at]an0key.co.uk, destined for
>> user-forum[at]somesite.com, it can rewrire it to
luke+somesite[at]an0key.co.uk?
>>
>> I am guessing it can, but havent a clue on the config.
>>
>> Cheers
>
> It can. Other have done such things in several ways, and a search of
the
> archives should find some examples.
>
> But you may not need to. You mentioned using IMAP.
>
> Member of 'many' lists, I simply use filters in the MUA to move or
copy
> incoming from each of many mailings lists to a folder or 'tree' of
> folders for the list(s).
>
> Any that might be needed when 'roaming' are server-side folders -
> otherwise 'Local'.
>
> With just one address, the MUA filter triggers, using this list as an
> example, on:
>
> 'return path' contains 'exim-users'
>
> = No need for a specialized addresses.
>
> = No need to rewrite the 'From:'
>
> HTH,
>
> Bill
>

Hi Bill,

Yes fully aware of the fact that you can move mails to certain folders,
but
this isn't fit for my solution, but thanks for pointing out anyways...

Just tried to look in the archive, but cant find anything, not sure what
I
should be looking for, i.e. The correct terminology...




--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


jethro.binks at strath

Jan 27, 2008, 1:48 PM

Post #4 of 30 (944 views)
Permalink
Re: Rewrite FROM address [In reply to]

On Sat, 26 Jan 2008, Luke Sheldrick wrote:

> However to reply to groups, I have subscribed to using this method,
> means the mail has to come from that address. The way I am doing it, is
> to setup a new imap account in my email software. However this is
> getting all a bit much :P
>
> Is there a way to get exim to rewrite the from, if the to is a paticular
> address. I.e. If a mail comes from luke[at]an0key.co.uk, destined for
> user-forum[at]somesite.com, it can rewrire it to
> luke+somesite[at]an0key.co.uk?
>
> I am guessing it can, but havent a clue on the config.

The answer with Exim is almost always "yes", however it's not necessarily
the easiest or best place to do it!

In this case, many sensible mail clients will allow you to configure
sending 'profiles' (or similar terminology), which either automatically
(based on matched patterns in the message to which you are replying) or
manually (based on you selecting from a list of profiles) set an
appropriate From: header.

In Pine there are the Role Rules, and at least Thunderbird will let you
set up identities attached to accounts, from which you can chose when
composing a message to set the appropriate From: address (and maybe select
other folders for filing sent messages).

I do not know if Entourage provides a comparable facility.

Jethro.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Jethro R Binks
Computing Officer, IT Services
University Of Strathclyde, Glasgow, UK

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


Luke.Sheldrick at an0key

Jan 27, 2008, 2:42 PM

Post #5 of 30 (938 views)
Permalink
Re: Rewrite FROM address [In reply to]

On 27/01/2008 21:48, "Jethro R Binks" <jethro.binks[at]strath.ac.uk> wrote:

> On Sat, 26 Jan 2008, Luke Sheldrick wrote:
>
>> However to reply to groups, I have subscribed to using this method,
>> means the mail has to come from that address. The way I am doing it, is
>> to setup a new imap account in my email software. However this is
>> getting all a bit much :P
>>
>> Is there a way to get exim to rewrite the from, if the to is a paticular
>> address. I.e. If a mail comes from luke[at]an0key.co.uk, destined for
>> user-forum[at]somesite.com, it can rewrire it to
>> luke+somesite[at]an0key.co.uk?
>>
>> I am guessing it can, but havent a clue on the config.
>
> The answer with Exim is almost always "yes", however it's not necessarily
> the easiest or best place to do it!
>
> In this case, many sensible mail clients will allow you to configure
> sending 'profiles' (or similar terminology), which either automatically
> (based on matched patterns in the message to which you are replying) or
> manually (based on you selecting from a list of profiles) set an
> appropriate From: header.
>
> In Pine there are the Role Rules, and at least Thunderbird will let you
> set up identities attached to accounts, from which you can chose when
> composing a message to set the appropriate From: address (and maybe select
> other folders for filing sent messages).
>
> I do not know if Entourage provides a comparable facility.
>
> Jethro.
>
> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
> Jethro R Binks
> Computing Officer, IT Services
> University Of Strathclyde, Glasgow, UK

Hi,

Thanks again, am fully aware of the fact that can do this client side as
stated in the first post, however am looking for an _exim_ solution, hense
why posting to tan _exim_ group.

Cheers



--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


Luke.Sheldrick at an0key

Jan 27, 2008, 2:43 PM

Post #6 of 30 (940 views)
Permalink
Re: Rewrite FROM address [In reply to]

On 27/01/2008 21:48, "Jethro R Binks" <jethro.binks[at]strath.ac.uk> wrote:

> On Sat, 26 Jan 2008, Luke Sheldrick wrote:
>
>> However to reply to groups, I have subscribed to using this method,
>> means the mail has to come from that address. The way I am doing it, is
>> to setup a new imap account in my email software. However this is
>> getting all a bit much :P
>>
>> Is there a way to get exim to rewrite the from, if the to is a paticular
>> address. I.e. If a mail comes from luke[at]an0key.co.uk, destined for
>> user-forum[at]somesite.com, it can rewrire it to
>> luke+somesite[at]an0key.co.uk?
>>
>> I am guessing it can, but havent a clue on the config.
>
> The answer with Exim is almost always "yes", however it's not necessarily
> the easiest or best place to do it!
>
> In this case, many sensible mail clients will allow you to configure
> sending 'profiles' (or similar terminology), which either automatically
> (based on matched patterns in the message to which you are replying) or
> manually (based on you selecting from a list of profiles) set an
> appropriate From: header.
>
> In Pine there are the Role Rules, and at least Thunderbird will let you
> set up identities attached to accounts, from which you can chose when
> composing a message to set the appropriate From: address (and maybe select
> other folders for filing sent messages).
>
> I do not know if Entourage provides a comparable facility.
>
> Jethro.
>
> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
> Jethro R Binks
> Computing Officer, IT Services
> University Of Strathclyde, Glasgow, UK

Hi,

Thanks again, am fully aware of the fact that can do this client side as
stated in the first post, however am looking for an _exim_ solution, hense
why posting to tan _exim_ group.

Cheers



--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


wbh at conducive

Jan 28, 2008, 12:35 AM

Post #7 of 30 (938 views)
Permalink
Re: Rewrite FROM address [In reply to]

Luke Sheldrick wrote:
> On 27/01/2008 21:48, "Jethro R Binks" <jethro.binks[at]strath.ac.uk> wrote:

*snipped*
>
> Hi,
>
> Thanks again, am fully aware of the fact that can do this client side as
> stated in the first post, however am looking for an _exim_ solution, hense
> why posting to tan _exim_ group.
>
> Cheers
>

We hope you find one that suits your needs 'soon'...

... 'coz whatever you are using at present seems to be doubling all your
posts with a one-minute delay between them.

;-)

Bill

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


don at quantainc

Jan 28, 2008, 12:53 PM

Post #8 of 30 (923 views)
Permalink
Re: Rewrite FROM address [In reply to]

On 2008-01-26 17:08, Luke Sheldrick wrote:
> Hello,
>
> Another quick question, I personally utilise receipent forwarding or
> whatever it is called, i.e. Luke+forumname@??? will come to
> luke@???
>
> However to reply to groups, I have subscribed to using this method, means
> the mail has to come from that address. The way I am doing it, is to
setup a
> new imap account in my email software. However this is getting all a bit
> much :P
>
> Is there a way to get exim to rewrite the from, if the to is a paticular
> address. I.e. If a mail comes from luke@???, destined for
> user-forum@???, it can rewrire it to luke+somesite@????
>
> I am guessing it can, but havent a clue on the config.
>
> Cheers
>
I just did this using a system filter (named myfilter here) and containing:

# Exim filter
if $h_to: contains "xxxxxx" then
headers remove "From"
headers remove "Reply_To:"
headers add "From: yyyyyy qqqqqq <zzzz[at]mydomain.com>"
endif

Add to the main config file something like:
system_filter = /etc/exim/myfilter
system_filter_user = exim





--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


jwblist3 at olympus

Jan 28, 2008, 2:31 PM

Post #9 of 30 (927 views)
Permalink
Re: Rewrite FROM address [In reply to]

On 1/26/08 4:56 PM, "W B Hacker" <wbh[at]conducive.org> wrote:

> Member of 'many' lists, I simply use filters in the MUA to move or copy
> incoming from each of many mailings lists to a folder or 'tree' of
> folders for the list(s).

And I do the same sort of thing, but with our server-side sorting rules
rather than MUA rules. Created before Sieve seemed viable with Exim--we
might well have just enabled Sieve (plus a UI for rule writing) were we
designing today rather than 2001.

(And then I read these lists with MS Entourage, which does a good job of
managing lists on its own--but this way I can switch MUAs without redoing
rules. Works for IMAP only, of course. And I may well switch.)

(I read this list from a server-side folder cleverly named EximUsers.)

-John



--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


exim-users at spodhuis

Jan 28, 2008, 3:25 PM

Post #10 of 30 (922 views)
Permalink
Re: Rewrite FROM address [In reply to]

On 2008-01-26 at 17:08 +0000, Luke Sheldrick wrote:
> Another quick question, I personally utilise receipent forwarding or
> whatever it is called, i.e. Luke+forumname[at]an0key.co.uk will come to
> luke[at]an0key.co.uk

Sub-addressing is the modern name.

Eg: RFC 5233 Sieve Email Filtering: Subaddress Extension

> However to reply to groups, I have subscribed to using this method, means
> the mail has to come from that address. The way I am doing it, is to setup a
> new imap account in my email software. However this is getting all a bit
> much :P

A whole new account, instead of delivering to a shared folder which you
subscribe to? Seems excessive.

> Is there a way to get exim to rewrite the from, if the to is a paticular
> address. I.e. If a mail comes from luke[at]an0key.co.uk, destined for
> user-forum[at]somesite.com, it can rewrire it to luke+somesite[at]an0key.co.uk?

Sure, but what about when you group reply to a user and the
forum/list/whatever is only CC'd?

> I am guessing it can, but havent a clue on the config.

Address rewriting, with a string expansion based on the recipient.
Failed expansions cause the rewrite to just be ignored. You want to do
this per-recipient, rather than trying to resolve rules about multiple
recipients in a list; however, this has the effect of "leaking" the
non-subaddressed email address to all recipients that you reply to, and
then any subsequent replies from them will include the non-subaddressed
form too.

All of the below is untested by me and may require further debugging by
you.

Let's say that /etc/mail/subaddress-maps/ contains files for each user
on your system, so that there's a file "luke" for you. In that file,
you will have lines looking like:

user-forum[at]somesite.com : luke+somesite

On the remote SMTP transport (pardon the very long lines):

max_rcpt = 1
headers_rewrite = *@an0key.co.uk ${lookup{$local_part@$domain}lsearch{/etc/mail/subaddress-maps/$1}{$value}fail}@an0key.co.uk f
return_path = ${lookup{$local_part@$domain}lsearch{/etc/mail/subaddress-maps/$1}{$value}fail}

Note that I provided three lines above; the second ends with a single
field "f"; if you don't see just three lines then check your wrapping.
For your config, insert \-line-continuations to taste.

Note that you can never have more than one RCPT per message for this to
work, hence "max_rcpt"; this has some performance implications but
they're probably insignificant for a personal server. You probably want
to have:
log_selector = +return_path_on_delivery
in your main config, to get the actual return path logged.

If you decide to put this data into an SQL DB or something instead of
the filesystem and you're not sure about the lookup caching, then you
might do this lookup once in the Router, setting "data = " and then
refer to this with $address_data in the transport. For that, you would
probably want to set a string ":FAIL:" instead of failing the expansion,
then explicitly fail the transport's expansions. Ie, change "fail" to
"{:FAIL:}" and then use:
return_path = ${if !eq{$address_data}{:FAIL:}{$address_data}fail}

-Phil

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


chris at eng

Jan 29, 2008, 5:43 AM

Post #11 of 30 (913 views)
Permalink
Re: Rewrite FROM address [In reply to]

On Mon, 28 Jan 2008, Phil Pennock wrote:

| On 2008-01-26 at 17:08 +0000, Luke Sheldrick wrote:

| > However to reply to groups, I have subscribed to using this method, means
| > the mail has to come from that address. The way I am doing it, is to setup a
| > new imap account in my email software. However this is getting all a bit
| > much :P
|
| A whole new account, instead of delivering to a shared folder which you
| subscribe to? Seems excessive.

Just to recap, we're discussing list posting with an automatic per-list
"send" address (outgoing mail).

My understanding is Luke means "account" in the MUA sense, which, for less
feature-laden MUAs, is probably the only way to achieve multiple "send"
addresses. I imagine each of these "accounts" connects to the IMAP server
with same username/passwd, but could be wrong.

Either way, I understand the reasons others have given that this sort of
thing may be best done in the MUA. As Jethro says, pine will definitely
do this with its rules/roles features. But lots of MUAs won't, and some
of those that do probably involve a less-than-succinct GUI. Those of us
who prefer proper text configs, and operate a more-or-less personal mail
server, may well feel an Exim solution is attractive...

I've been thinking about doing this myself, but haven't gotten round to
working out the details. Phil - your suggestion is really helpful as a
starting point - thanks.


| Address rewriting, with a string expansion based on the recipient.
| Failed expansions cause the rewrite to just be ignored. You want to do
| this per-recipient, rather than trying to resolve rules about multiple
| recipients in a list; however, this has the effect of "leaking" the
| non-subaddressed email address to all recipients that you reply to, and
| then any subsequent replies from them will include the non-subaddressed
| form too.

I see the problem. Perhaps just as well to use the per-list address for
direct replies too. Haven't fully thought thru all the consequences yet...


| max_rcpt = 1
| headers_rewrite = *@an0key.co.uk ${lookup{$local_part@$domain}lsearch{/etc/mail/subaddress-maps/$1}{$value}fail}@an0key.co.uk f
| return_path = ${lookup{$local_part@$domain}lsearch{/etc/mail/subaddress-maps/$1}{$value}fail}

May not need to change the return_path - in most cases mangling the From:
header (as used for access control by most lists) will be sufficient.

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


Luke.Sheldrick at an0key

Jan 29, 2008, 11:37 AM

Post #12 of 30 (913 views)
Permalink
Re: Rewrite FROM address [In reply to]

On 29/01/2008 13:43, "Chris Edwards" <chris[at]eng.gla.ac.uk> wrote:

> On Mon, 28 Jan 2008, Phil Pennock wrote:
>
> | On 2008-01-26 at 17:08 +0000, Luke Sheldrick wrote:
>
> | > However to reply to groups, I have subscribed to using this method, means
> | > the mail has to come from that address. The way I am doing it, is to setup
> a
> | > new imap account in my email software. However this is getting all a bit
> | > much :P
> |
> | A whole new account, instead of delivering to a shared folder which you
> | subscribe to? Seems excessive.
>
> Just to recap, we're discussing list posting with an automatic per-list
> "send" address (outgoing mail).
>
> My understanding is Luke means "account" in the MUA sense, which, for less
> feature-laden MUAs, is probably the only way to achieve multiple "send"
> addresses. I imagine each of these "accounts" connects to the IMAP server
> with same username/passwd, but could be wrong.

Correct, all the 'accounts' are all in fact attached to the same imap
account, with the same user name / pwd, just different 'from' email
addresses.

> Either way, I understand the reasons others have given that this sort of
> thing may be best done in the MUA. As Jethro says, pine will definitely
> do this with its rules/roles features. But lots of MUAs won't, and some
> of those that do probably involve a less-than-succinct GUI. Those of us
> who prefer proper text configs, and operate a more-or-less personal mail
> server, may well feel an Exim solution is attractive...

My setup is 'almost' personal, in this context it is anyways, as use my
personally infrastructure for testing / learning and to host my own stuff.
As I often change the internal workings, i.e. Testing different platforms,
MTAs, servers... Etc it is difficult to use rule based solutions i.e. In the
mail client, or where the mail is hosted, as it's often changing.

Having said that, my edge servers (both incoming and outgoing), remain the
same, both running exim. So if I can implement the solution here, will save
me lots of time, and effort.

> I've been thinking about doing this myself, but haven't gotten round to
> working out the details. Phil - your suggestion is really helpful as a
> starting point - thanks.
>
>
> | Address rewriting, with a string expansion based on the recipient.
> | Failed expansions cause the rewrite to just be ignored. You want to do
> | this per-recipient, rather than trying to resolve rules about multiple
> | recipients in a list; however, this has the effect of "leaking" the
> | non-subaddressed email address to all recipients that you reply to, and
> | then any subsequent replies from them will include the non-subaddressed
> | form too.

The solution only need look at the TO, if the TO has/includes the 'group,
then I would want the FROM to change to whatever was set in the text file.


> I see the problem. Perhaps just as well to use the per-list address for
> direct replies too. Haven't fully thought thru all the consequences yet...

:)

> | max_rcpt = 1
> | headers_rewrite = *@an0key.co.uk
> ${lookup{$local_part@$domain}lsearch{/etc/mail/subaddress-maps/$1}{$value}fail
> }@an0key.co.uk f
> | return_path =
>
${lookup{$local_part@$domain}lsearch{/etc/mail/subaddress-maps/$1}{$value}fail>
}
>

> May not need to change the return_path - in most cases mangling the From:
> header (as used for access control by most lists) will be sufficient.

P.s. Thanks for those who have suggested things so far :)



--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


Luke at Sheldrick

Feb 25, 2008, 6:02 AM

Post #13 of 30 (821 views)
Permalink
Re: Rewrite FROM address [In reply to]

Hi Phil,

Hope you don't mind me contacting you again, however have just come to look
at this again, and have had a thought.

My config for my transporters looks like:

redirect:
driver = redirect
local_part_suffix = +* : -*
local_part_suffix_optional
data = ${lookup{$local_part@$domain}
lsearch{/etc/exim/exim-redirect-mail-for-this-list-of-users.txt}}

internal:
driver = manualroute
local_part_suffix = +* : -*
local_part_suffix_optional
domains = +relay_to_domains
transport = remote_smtp
route_data =
${lookup{$domain}partial-lsearch{/etc/exim/exim-deliver-to-these-servers.txt
}}

external:
driver = manualroute
domains = ! +relay_to_domains
transport = remote_smtp
ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
route_list = * lnd04.an0key.net
no_more


how would I phrase you extra config to allow the rewrites?





-----Original Message-----
From: Phil Pennock [mailto:exim-users[at]spodhuis.org]
Sent: 28 January 2008 23:25
To: Luke Sheldrick
Cc: Exim Mailing List
Subject: Re: [exim] Rewrite FROM address

On 2008-01-26 at 17:08 +0000, Luke Sheldrick wrote:
> Another quick question, I personally utilise receipent forwarding or
> whatever it is called, i.e. Luke+forumname[at]an0key.co.uk will come to
> luke[at]an0key.co.uk

Sub-addressing is the modern name.

Eg: RFC 5233 Sieve Email Filtering: Subaddress Extension

> However to reply to groups, I have subscribed to using this method, means
> the mail has to come from that address. The way I am doing it, is to setup
a
> new imap account in my email software. However this is getting all a bit
> much :P

A whole new account, instead of delivering to a shared folder which you
subscribe to? Seems excessive.

> Is there a way to get exim to rewrite the from, if the to is a paticular
> address. I.e. If a mail comes from luke[at]an0key.co.uk, destined for
> user-forum[at]somesite.com, it can rewrire it to luke+somesite[at]an0key.co.uk?

Sure, but what about when you group reply to a user and the
forum/list/whatever is only CC'd?

> I am guessing it can, but havent a clue on the config.

Address rewriting, with a string expansion based on the recipient.
Failed expansions cause the rewrite to just be ignored. You want to do
this per-recipient, rather than trying to resolve rules about multiple
recipients in a list; however, this has the effect of "leaking" the
non-subaddressed email address to all recipients that you reply to, and
then any subsequent replies from them will include the non-subaddressed
form too.

All of the below is untested by me and may require further debugging by
you.

Let's say that /etc/mail/subaddress-maps/ contains files for each user
on your system, so that there's a file "luke" for you. In that file,
you will have lines looking like:

user-forum[at]somesite.com : luke+somesite

On the remote SMTP transport (pardon the very long lines):

max_rcpt = 1
headers_rewrite = *@an0key.co.uk
${lookup{$local_part@$domain}lsearch{/etc/mail/subaddress-maps/$1}{$value}fa
il}@an0key.co.uk f
return_path =
${lookup{$local_part@$domain}lsearch{/etc/mail/subaddress-maps/$1}{$value}fa
il}

Note that I provided three lines above; the second ends with a single
field "f"; if you don't see just three lines then check your wrapping.
For your config, insert \-line-continuations to taste.

Note that you can never have more than one RCPT per message for this to
work, hence "max_rcpt"; this has some performance implications but
they're probably insignificant for a personal server. You probably want
to have:
log_selector = +return_path_on_delivery
in your main config, to get the actual return path logged.

If you decide to put this data into an SQL DB or something instead of
the filesystem and you're not sure about the lookup caching, then you
might do this lookup once in the Router, setting "data = " and then
refer to this with $address_data in the transport. For that, you would
probably want to set a string ":FAIL:" instead of failing the expansion,
then explicitly fail the transport's expansions. Ie, change "fail" to
"{:FAIL:}" and then use:
return_path = ${if !eq{$address_data}{:FAIL:}{$address_data}fail}

-Phil


--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


exim-users at spodhuis

Feb 26, 2008, 2:33 AM

Post #14 of 30 (821 views)
Permalink
Re: Rewrite FROM address [In reply to]

On 2008-02-25 at 14:02 -0000, Luke Sheldrick wrote:
> My config for my transporters looks like:

> redirect:
> internal:
> external:

> how would I phrase you extra config to allow the rewrites?

You listed your Routers; these are the list of options to decide how to
deal with an address, with each Router tried in turn.

Notice that both the "internal" and "external" Routers contain:
"transport = remote_smtp"
which sets the transport to use for delivery of the copy of the email
destined for that address. The Transports are a collection of
techniques to use, as an unordered set; they're only used when
referenced by a Router.

The settings I described are transport settings and belong on
"remote_smtp" in its definition somewhere after "begin transports".

Regards,
-Phil

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


luke at sheldrick

Mar 2, 2008, 3:33 PM

Post #15 of 30 (782 views)
Permalink
Re: Rewrite FROM address [In reply to]

Hi again Phil,

I get the below error when trying to start exim with your excert:

Starting exim: 2008-03-02 23:14:14 Exim configuration error in line 656 of /etc/exim/exim.conf:
missing rewrite replacement string

using the following syntax under the transporters section

remote_smtp:
driver = smtp
headers_rewrite = *@an0key.co.uk${lookup{$local_part@$domain}lsearch{/etc/exim/redir/$1}{$value}fail}@an0key.co.uk
return_path = ${lookup{$local_part@$domain}lsearch{/etc/exim/redir/$1}{$value}fail}



>-----Original Message-----
>From: exim-users-bounces[at]exim.org [mailto:exim-users-bounces[at]exim.org] On
>Behalf Of Phil Pennock
>Sent: 26 February 2008 10:34
>To: Luke Sheldrick
>Cc: exim-users[at]exim.org
>Subject: Re: [exim] Rewrite FROM address
>
>On 2008-02-25 at 14:02 -0000, Luke Sheldrick wrote:
>> My config for my transporters looks like:
>
>> redirect:
>> internal:
>> external:
>
>> how would I phrase you extra config to allow the rewrites?
>
>You listed your Routers; these are the list of options to decide how to
>deal with an address, with each Router tried in turn.
>
>Notice that both the "internal" and "external" Routers contain:
> "transport = remote_smtp"
>which sets the transport to use for delivery of the copy of the email
>destined for that address. The Transports are a collection of
>techniques to use, as an unordered set; they're only used when
>referenced by a Router.
>
>The settings I described are transport settings and belong on
>"remote_smtp" in its definition somewhere after "begin transports".
>
>Regards,
>-Phil
>
>--
>## List details at http://lists.exim.org/mailman/listinfo/exim-users
>## Exim details at http://www.exim.org/
>## Please use the Wiki with this list - http://wiki.exim.org/

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


exim-users at spodhuis

Mar 2, 2008, 4:35 PM

Post #16 of 30 (785 views)
Permalink
Re: Rewrite FROM address [In reply to]

On 2008-03-02 at 23:33 +0000, Luke Sheldrick wrote:
> I get the below error when trying to start exim with your excert:
>
> Starting exim: 2008-03-02 23:14:14 Exim configuration error in line 656 of /etc/exim/exim.conf:
> missing rewrite replacement string

That's because you missed out on some spaces and fields.

> using the following syntax under the transporters section
>
> remote_smtp:
> driver = smtp
> headers_rewrite = *@an0key.co.uk${lookup{$local_part@$domain}lsearch{/etc/exim/redir/$1}{$value}fail}@an0key.co.uk
> return_path = ${lookup{$local_part@$domain}lsearch{/etc/exim/redir/$1}{$value}fail}

I wrote:

max_rcpt = 1
headers_rewrite = *@an0key.co.uk ${lookup{$local_part@$domain}lsearch{/etc/mail/subaddress-maps/$1}{$value}fail}@an0key.co.uk f
return_path = ${lookup{$local_part@$domain}lsearch{/etc/mail/subaddress-maps/$1}{$value}fail}

(and also mentioned the long lines and wrapping)

Split up with newlines, the second line there is:

headers_rewrite = *@an0key.co.uk \
${lookup{$local_part@$domain}lsearch{/etc/mail/subaddress-maps/$1}{$value}fail}@an0key.co.uk \
f

So, a space between the match field and the replacement field, then
another space between the replacement field and the 'f' flag.

-Phil

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


luke at sheldrick

Mar 2, 2008, 5:09 PM

Post #17 of 30 (783 views)
Permalink
Re: Rewrite FROM address [In reply to]

Hey,

I've got the config the same now :)

Am now getting the following error in the log files, with mail just deferring tin the Q.

R=internal T=remote_smtp defer (-1): Failed to expand return path "${lookup{$local_part@$domain}lsearch{/etc/exim/redir/$1}{$value}fail}": /etc/exim/redir/ is not a regular file (lsearch lookup)



--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


exim-users at spodhuis

Mar 3, 2008, 2:29 AM

Post #18 of 30 (778 views)
Permalink
Re: Rewrite FROM address [In reply to]

On 2008-03-03 at 01:09 +0000, Luke Sheldrick wrote:
> I've got the config the same now :)
>
> Am now getting the following error in the log files, with mail just deferring tin the Q.
>
> R=internal T=remote_smtp defer (-1): Failed to expand return path "${lookup{$local_part@$domain}lsearch{/etc/exim/redir/$1}{$value}fail}": /etc/exim/redir/ is not a regular file (lsearch lookup)

Can you please post the entire Router and get it posted without wrapping
any whitespace?

Heck, if need be uuencode the snippet? Or base64 encode it?

Eg, copy it to a file myrouter.txt and then run:

$ b64encode myrouter.txt myrouter.txt >includethis
or
$ perl -MMIME::Base64 -pe '$_=encode_base64 $_' <myrouter.txt >includethis

and then paste "includethis" into the email.

Thanks,
-Phil

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


luke at sheldrick

Mar 4, 2008, 3:27 AM

Post #19 of 30 (756 views)
Permalink
Re: Rewrite FROM address [In reply to]

Hi Phil,

Just scraped the whole exim.conf, hopefully this'll be alright?

http://luke.sheldrick.co.uk/Files/exim/exim.conf.txt


On 03/03/2008 10:29, "Phil Pennock" <exim-users[at]spodhuis.org> wrote:

On 2008-03-03 at 01:09 +0000, Luke Sheldrick wrote:
> I've got the config the same now :)
>
> Am now getting the following error in the log files, with mail just deferring tin the Q.
>
> R=internal T=remote_smtp defer (-1): Failed to expand return path "${lookup{$local_part@$domain}lsearch{/etc/exim/redir/$1}{$value}fail}": /etc/exim/redir/ is not a regular file (lsearch lookup)

Can you please post the entire Router and get it posted without wrapping
any whitespace?

Heck, if need be uuencode the snippet? Or base64 encode it?

Eg, copy it to a file myrouter.txt and then run:

$ b64encode myrouter.txt myrouter.txt >includethis
or
$ perl -MMIME::Base64 -pe '$_=encode_base64 $_' <myrouter.txt >includethis

and then paste "includethis" into the email.

Thanks,
-Phil

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


exim-users at spodhuis

Mar 5, 2008, 1:03 AM

Post #20 of 30 (754 views)
Permalink
Re: Rewrite FROM address [In reply to]

On 2008-03-04 at 11:27 +0000, Luke Sheldrick wrote:
> Just scraped the whole exim.conf, hopefully this'll be alright?
>
> http://luke.sheldrick.co.uk/Files/exim/exim.conf.txt

That appears to be your config _without_ the attempt to rewrite the
return path.

-Phil

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


luke at sheldrick

Mar 5, 2008, 4:06 AM

Post #21 of 30 (753 views)
Permalink
Re: Rewrite FROM address [In reply to]

So I did, sorry..

Try http://luke.sheldrick.co.uk/Files/exim/exim.conf.rewrite.txt
________________________________________
From: Phil Pennock [exim-users[at]spodhuis.org]
Sent: Wednesday, March 05, 2008 9:03 AM
To: Luke Sheldrick
Cc: exim-users[at]exim.org
Subject: Re: [exim] Rewrite FROM address

On 2008-03-04 at 11:27 +0000, Luke Sheldrick wrote:
> Just scraped the whole exim.conf, hopefully this'll be alright?
>
> http://luke.sheldrick.co.uk/Files/exim/exim.conf.txt

That appears to be your config _without_ the attempt to rewrite the
return path.

-Phil

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


exim-users at spodhuis

Mar 6, 2008, 1:36 AM

Post #22 of 30 (753 views)
Permalink
Re: Rewrite FROM address [In reply to]

On 2008-03-05 at 12:06 +0000, Luke Sheldrick wrote:
> So I did, sorry..
>
> Try http://luke.sheldrick.co.uk/Files/exim/exim.conf.rewrite.txt

Okay, my untested example had a bug. This is what I get for only ever
seeing your mails after 1am ;^) -- it's embarrassing that I didn't spot
this before now.

In fact, the second error message was even clear about the fact that the
problem was in the return_path now and that the headers_rewrite problem
from your transcription mishap had been solved.

return_path = ${lookup{$local_part@$domain}lsearch{/etc/mail/subaddress-maps/$1}{$value}fail}

There is no $1 because there is no comparison setting it because this
isn't a rewrite, it's a straight-forward string expansion.

Change the $1 for $local_part instead.

You can also safely make the same change in the headers_rewrite, for
consistency, if you like.

Bah, I had a nagging feeling that it might be better to switch from $1
to $local_part but couldn't see a reason to switch so told myself I was
being silly, it was fine. :^( Apparently my subconscious was more
awake than I was.

Sorry,
-Phil

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


luke at sheldrick

Mar 8, 2008, 9:33 AM

Post #23 of 30 (736 views)
Permalink
Re: Rewrite FROM address [In reply to]

Hi again Phil,

Getting closer, :)

Howrver have changed $1 for $local_part, and it does work, however there are a couple of glitches.

For some reason it isnt picking up the @an0key.co.uk on the domain when it's rewriting the headers, instead it is rewriting just with the new local part. If I put the full email in txt file it does work.

Well kind of, I tested a mail, and got the below headers

From: "Luke Sheldrick" <Luke[at]an0key.co.uk>
To: <luke.sheldrick[at]ntt.eu>
Return-Path: luke+forntttest[at]an0key.net

So the return path is working, just not the from.

Also if exim cannot find the txt file for a user in the subaddress folder (or redir as I called it) it is failing the messages.. Is there a way to get around this, i.e. If there is now file, to keep it as it were?

And one more :P could we rewrite the script slightly, so it rewrites the complete email address? As at the moment will only do it for an0key.co.uk, and whilst there is only three domains on this setup (i.e. My home / test env) would be good if in the redir folder I could put luke[at]an0key.co.uk for example?

Really appreciate your help..

On 06/03/2008 09:36, "Phil Pennock" <exim-users[at]spodhuis.org> wrote:

On 2008-03-05 at 12:06 +0000, Luke Sheldrick wrote:
> So I did, sorry..
>
> Try http://luke.sheldrick.co.uk/Files/exim/exim.conf.rewrite.txt

Okay, my untested example had a bug. This is what I get for only ever
seeing your mails after 1am ;^) -- it's embarrassing that I didn't spot
this before now.

In fact, the second error message was even clear about the fact that the
problem was in the return_path now and that the headers_rewrite problem
from your transcription mishap had been solved.

return_path = ${lookup{$local_part@$domain}lsearch{/etc/mail/subaddress-maps/$1}{$value}fail}

There is no $1 because there is no comparison setting it because this
isn't a rewrite, it's a straight-forward string expansion.

Change the $1 for $local_part instead.

You can also safely make the same change in the headers_rewrite, for
consistency, if you like.

Bah, I had a nagging feeling that it might be better to switch from $1
to $local_part but couldn't see a reason to switch so told myself I was
being silly, it was fine. :^( Apparently my subconscious was more
awake than I was.

Sorry,
-Phil

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


luke at sheldrick

Mar 8, 2008, 9:34 AM

Post #24 of 30 (734 views)
Permalink
Re: Rewrite FROM address [In reply to]

Forgot to mention I scp of the exim dir can be found:

http://luke.sheldrick.co.uk/files/exim/

In redir, luke & luke.sheldrick are the same file, but iis wouldn't play nice with a file with no extension.


On 08/03/2008 16:33, "Luke" <luke[at]sheldrick.co.uk> wrote:

Hi again Phil,

Getting closer, :)

Howrver have changed $1 for $local_part, and it does work, however there are a couple of glitches.

For some reason it isnt picking up the @an0key.co.uk on the domain when it's rewriting the headers, instead it is rewriting just with the new local part. If I put the full email in txt file it does work.

Well kind of, I tested a mail, and got the below headers

From: "Luke Sheldrick" <Luke[at]an0key.co.uk>
To: <luke.sheldrick[at]ntt.eu>
Return-Path: luke+forntttest[at]an0key.net

So the return path is working, just not the from.

Also if exim cannot find the txt file for a user in the subaddress folder (or redir as I called it) it is failing the messages.. Is there a way to get around this, i.e. If there is now file, to keep it as it were?

And one more :P could we rewrite the script slightly, so it rewrites the complete email address? As at the moment will only do it for an0key.co.uk, and whilst there is only three domains on this setup (i.e. My home / test env) would be good if in the redir folder I could put luke[at]an0key.co.uk for example?

Really appreciate your help..

On 06/03/2008 09:36, "Phil Pennock" <exim-users[at]spodhuis.org> wrote:

On 2008-03-05 at 12:06 +0000, Luke Sheldrick wrote:
> So I did, sorry..
>
> Try http://luke.sheldrick.co.uk/Files/exim/exim.conf.rewrite.txt

Okay, my untested example had a bug. This is what I get for only ever
seeing your mails after 1am ;^) -- it's embarrassing that I didn't spot
this before now.

In fact, the second error message was even clear about the fact that the
problem was in the return_path now and that the headers_rewrite problem
from your transcription mishap had been solved.

return_path = ${lookup{$local_part@$domain}lsearch{/etc/mail/subaddress-maps/$1}{$value}fail}

There is no $1 because there is no comparison setting it because this
isn't a rewrite, it's a straight-forward string expansion.

Change the $1 for $local_part instead.

You can also safely make the same change in the headers_rewrite, for
consistency, if you like.

Bah, I had a nagging feeling that it might be better to switch from $1
to $local_part but couldn't see a reason to switch so told myself I was
being silly, it was fine. :^( Apparently my subconscious was more
awake than I was.

Sorry,
-Phil

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


exim-users at spodhuis

Mar 9, 2008, 3:54 AM

Post #25 of 30 (732 views)
Permalink
Re: Rewrite FROM address [In reply to]

On 2008-03-08 at 16:33 +0000, Luke Sheldrick wrote:
> Howrver have changed $1 for $local_part, and it does work, however there are a couple of glitches.

Okay, again it's after 3am and I have a couple of glasses of wine in me,
but I see why I used $1 before, not $local_part. $local_part is the
recipient local part, $1 was matched against the sender.

In the header rewrite, use $1 as originally stated.
In the return_path setting, instead of $1 or $local_part use
$sender_address_local_part -- this just gets longer and longer. ;)

> Also if exim cannot find the txt file for a user in the subaddress
> folder (or redir as I called it) it is failing the messages.. Is there
> a way to get around this, i.e. If there is now file, to keep it as it
> were?

Oh. If the file doesn't exist, it's probably being treated as an
unforced failure because the lookup didn't exist, not as a forced
failure (key not found so using the "fail" clause).

Oh, and the return_path wasn't setting the domain.

Okay, so now we're up to:

return_path = ${if exists {/etc/mail/subaddres-maps/$sender_address_local_part} \
{${lookup{$local_part@$domain}lsearch{/etc/mail/subaddress-maps/$sender_address_local_part}{$value@$sender_address_domain}fail}}\
{$return_path}}

Having fun yet? :^)

> And one more :P could we rewrite the script slightly, so it rewrites
> the complete email address? As at the moment will only do it for
> an0key.co.uk, and whilst there is only three domains on this setup
> (i.e. My home / test env) would be good if in the redir folder I could
> put luke[at]an0key.co.uk for example?

Hey, at last one which isn't my fault, but just something not originally
asked for. Cool.

Okay, for the return_path this makes it shorter, since instead of
$sender_address_local_part you can just use $sender_address (in both
places).

For the headers_rewrite, use *@* and then $2 to refer to the domain;
once in the filename ($1@$2) and once when constructing the address.

So, if I'm not mistaken (again) this should be:

max_rcpt = 1
headers_rewrite = *@* ${lookup{$local_part@$domain}lsearch{/etc/mail/subaddress-maps/$1@$2}{$value}fail}@$2 f
return_path = ${if exists {/etc/mail/subaddres-maps/$sender_address} \
{${lookup{$local_part@$domain}lsearch{/etc/mail/subaddress-maps/$sender_address}{$value@$sender_address_domain}fail}}\
{$return_path}}

Note that this assumes that the domain remains unchanged. If you want
to be able to change the domain too, then include the domain in the
value in the lookup file instead and use:

max_rcpt = 1
headers_rewrite = *@* ${lookup{$local_part@$domain}lsearch{/etc/mail/subaddress-maps/$1@$2}{$value}fail} f
return_path = ${if exists {/etc/mail/subaddres-maps/$sender_address} \
{${lookup{$local_part@$domain}lsearch{/etc/mail/subaddress-maps/$sender_address}{$value}fail}}\
{$return_path}}

Note further that this still remains untested by me. Caveat emptor.

Regards,
-Phil

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/

First page Previous page 1 2 Next page Last page  View All exim users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.