Mailing List Archive

Difficulty getting Exim Address rewriting working on Ubuntu Linux
Greetings,

Häid Jõule! / Joyful Christmas! ????????????????

We are having difficulty getting Exim Address rewriting working on Ubuntu Linux.

The steps I have taken:

1) Configured the Debian / Ubuntu style configuration over to:

dc_use_split_config='true'

2) Put rewrite rules here: /etc/exim4/conf.d/rewrite/00_exim4-config_header

root@hostname.subdomain.realdomain.com realemailaddress@realdomain.com FTfrst
root@realdomain.com realemailaddress@realdomain.com FTfrst

3) Ran the following commands to update the Exim configuration:

sudo update-exim4.conf
sudo service exim4 restart

Send a test email, and it properly goes out to realemailaddress@realdomain.com

So then I wanted to wildcard so that I did not need to think of every possible variation the local mail might be coming from in order to bridge it to the real Internet.

Attempted rules:

root realemailaddress@realdomain.com FTfrst
hostname realemailaddress@realdomain.com FTfrst
subdomain realemailaddress@realdomain.com FTfrst

Those did not fire.

So I updated the syntax to:

root* realemailaddress@realdomain.com FTfrst
*hostname* realemailaddress@realdomain.com FTfrst
*subdomain* realemailaddress@realdomain.com FTfrst

Those still do not fire. However....

* realemailaddress@realdomain.com FTfrst

DOES work as an option!

I simplified the rewrite option list to:

* realemailaddress@realdomain.com Eh

I found test program: exim -brw root

So am using that to now test the rules to see if they fire or not. The objective is to get exim to state that it will send the mail to realemailaddress@realdomain.com address. The only way I can
wildcard get Exim to do the rewrite is to run on the bare "*" rule.

What is wrong that other wild card attempts are not successful?

I am thankful,

--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Difficulty getting Exim Address rewriting working on Ubuntu Linux [ In reply to ]
On 12/25/23 15:12, Michael Lueck via Exim-users wrote:
> What is wrong that other wild card attempts are not successful?

Only asterisks at the start of a local-part (or domain) are usable
in that sort of match element. You could, perhaps, use a full RE
instead.


Docs:
https://exim.org/exim-html-current/doc/html/spec_html/ch-address_rewriting.html section 5
https://exim.org/exim-html-current/doc/html/spec_html/ch-address_rewriting.html section 5
--
Cheers,
Jeremy


--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Difficulty getting Exim Address rewriting working on Ubuntu Linux [ In reply to ]
Greetings Jeremy,


Jeremy Harris wrote:
> Author: Jeremy Harris
> Date: 2023-12-25 13:51 -500
> To: exim-users
> Subject: [exim] Re: Difficulty getting Exim Address rewriting working on Ubuntu Linux
> On 12/25/23 15:12, Michael Lueck via Exim-users wrote:
>> What is wrong that other wild card attempts are not successful?
>
> Only asterisks at the start of a local-part (or domain) are usable
> in that sort of match element. You could, perhaps, use a full RE
> instead.


Ahhhh.... I perceived you mean that the asterisks only worked on either the address or system name side of the entire email address.

So I changed my rules on the test VM system to:


begin rewrite
root@* realemailaddress@realdomain.com Eh
*@hostname* realemailaddress@realdomain.com Eh
*@*subdomain* realemailaddress@realdomain.com Eh



And these rewrite rules worked with the command line test, and then sending real test emails.

Waiting to update the configuration on the real server.

I anticipate success there as well.



> Docs:
> https://exim.org/exim-html-current/doc/html/spec_html/ch-address_rewriting.html section 5
> https://exim.org/exim-html-current/doc/html/spec_html/ch-address_rewriting.html section 5


Yes, that page I had been working from to build these rewrite rules.



I appreciate the assistance very much!

I am thankful,

--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Difficulty getting Exim Address rewriting working on Ubuntu Linux [ In reply to ]
Greetings,

Michael Lueck wrote:
>
> So I changed my rules on the test VM system to:
>
>
> begin rewrite
> root@*                                             realemailaddress@realdomain.com   Eh
> *@hostname*                                        realemailaddress@realdomain.com   Eh
> *@*subdomain*                                      realemailaddress@realdomain.com   Eh
>
>
>
> And these rewrite rules worked with the command line test, and then sending real test emails.


Actually, upon further testing.... seems that just the root@* rule finally works. The rest do not.

I switched out root@ for another valid account on the server, and then had the full @hostname.subdomain.realdomain.com and neither of the hostname nor subdomain rules would fire. I tested them in the
VM having only one rewrite rule active at a time, then used the command line tester interface of Exim.

Perhaps did I still misunderstand about Exim address rewriting rule syntax?

I am thankful,

--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Difficulty getting Exim Address rewriting working on Ubuntu Linux [ In reply to ]
Greetings again,

Michael Lueck wrote:
> Michael Lueck wrote:
>>
>> So I changed my rules on the test VM system to:
>>
>>
>> begin rewrite
>> root@*                                             realemailaddress@realdomain.com   Eh
>> *@hostname*                                        realemailaddress@realdomain.com   Eh
>> *@*subdomain*                                      realemailaddress@realdomain.com   Eh
>>
>>
>>
>> And these rewrite rules worked with the command line test, and then sending real test emails.
>
>
> Actually, upon further testing.... seems that just the root@* rule finally works. The rest do not.
>
> I switched out root@ for another valid account on the server, and then had the full @hostname.subdomain.realdomain.com and neither of the hostname nor subdomain rules would fire. I tested them in the
> VM having only one rewrite rule active at a time, then used the command line tester interface of Exim.
>
> Perhaps did I still misunderstand about Exim address rewriting rule syntax?

I have read through the Exim Address Rewriting documentation now several times.
https://www.exim.org/exim-html-current/doc/html/spec_html/ch-address_rewriting.html

Right here is a similar example rewrite rule:

7. Rewriting examples
Here is an example of the two common rewriting paradigms:

*@*.hitch.fict.example


That has a wild card as the address side and a wild card in the host side of the address. It looks very similar to the rules I am attempting.

I do not understand what I am doing incorrectly that Exim will not rewrite the host side of the email addresses. Please kindly explain.

I have tried the above, and also tweaked slightly to this syntax:

begin rewrite
root@* realemailaddress@realdomain.com Eh
*@hostname.* realemailaddress@realdomain.com Eh
*@*.subdomain.* realemailaddress@realdomain.com Eh


The host side rewrite rules fail to rewrite. Why?

I am thankful,

--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Difficulty getting Exim Address rewriting working on Ubuntu Linux [ In reply to ]
On 12/28/23 14:37, Michael Lueck via Exim-users wrote:
> The host side rewrite rules fail to rewrite. Why?

The "reswriting patterns" section of the docs says
"The source pattern ... is in fact processed as a single-item address list".

Looking up the bit of docs describing address lists, we find
"A certain amount of wildcarding is permitted. [...]
If the local parts match, the domain is checked in exactly the same way as for a pattern in a domain list"

And then about domain lists:
"If a pattern starts with an asterisk, the remaining characters of the pattern are compared with the terminating characters of the domain"

Note: "start with". It does not say you can use an asterisk somewhere else.
--
Cheers,
Jeremy


--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Difficulty getting Exim Address rewriting working on Ubuntu Linux [ In reply to ]
So what I do with rewriting:
I have to files containing the users inside and the users outside. Working form e fine.


begin rewrite
##out Emails
*@yourinside.domain "${extract{remote} {${lookup{$0}lsearch{/etc/exim4/data/lokal_remote}{$value}fail}}{$value} fail}" rsfF

##coming in Emails
^[a-z-0-9\.\-]+@(youroutside.domain)\.de "${extract{lokal} {${lookup{$0}lsearch{/etc/exim4/data/remote_lokal}{$value}fail}}{$value} fail}" ST

Examaple file: lokal_remote:
abcd@yourinside.domain: remote=abcd@youroutside.domain

Examaple file: remote_lokal:
abcd@youroutside.domain: lokal=abcd@yourinside.domain

Greetings
Daniel

-----Ursprüngliche Nachricht-----
Von: Michael Lueck via Exim-users [mailto:exim-users@lists.exim.org]
Gesendet: Donnerstag, 28. Dezember 2023 15:38
An: exim-users@lists.exim.org
Betreff: [exim] Re: Difficulty getting Exim Address rewriting working on Ubuntu Linux

Greetings again,

Michael Lueck wrote:
> Michael Lueck wrote:
>>
>> So I changed my rules on the test VM system to:
>>
>>
>> begin rewrite
>> root@*
>> realemailaddress@realdomain.com Eh
>> *@hostname*
>> realemailaddress@realdomain.com Eh
>> *@*subdomain*
>> realemailaddress@realdomain.com Eh
>>
>>
>>
>> And these rewrite rules worked with the command line test, and then sending real test emails.
>
>
> Actually, upon further testing.... seems that just the root@* rule finally works. The rest do not.
>
> I switched out root@ for another valid account on the server, and then
> had the full @hostname.subdomain.realdomain.com and neither of the hostname nor subdomain rules would fire. I tested them in the VM having only one rewrite rule active at a time, then used the command line tester interface of Exim.
>
> Perhaps did I still misunderstand about Exim address rewriting rule syntax?

I have read through the Exim Address Rewriting documentation now several times.
https://www.exim.org/exim-html-current/doc/html/spec_html/ch-address_rewriting.html

Right here is a similar example rewrite rule:

7. Rewriting examples
Here is an example of the two common rewriting paradigms:

*@*.hitch.fict.example


That has a wild card as the address side and a wild card in the host side of the address. It looks very similar to the rules I am attempting.

I do not understand what I am doing incorrectly that Exim will not rewrite the host side of the email addresses. Please kindly explain.

I have tried the above, and also tweaked slightly to this syntax:

begin rewrite
root@* realemailaddress@realdomain.com Eh
*@hostname.* realemailaddress@realdomain.com Eh
*@*.subdomain.* realemailaddress@realdomain.com Eh


The host side rewrite rules fail to rewrite. Why?

I am thankful,

--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Difficulty getting Exim Address rewriting working on Ubuntu Linux [ In reply to ]
On 12/28/23 15:11, Daniel Müller via Exim-users wrote:
> So what I do with rewriting:

As I said previously: use a regex
--
Cheers,
Jeremy


--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Difficulty getting Exim Address rewriting working on Ubuntu Linux [ In reply to ]
Greetings Jeremy and Daniel,


> On 12/28/23 14:37, Michael Lueck via Exim-users wrote:
>> The host side rewrite rules fail to rewrite. Why?
>
> The "reswriting patterns" section of the docs says
> "The source pattern ... is in fact processed as a single-item address list".
>
> Looking up the bit of docs describing address lists, we find
> "A certain amount of wildcarding is permitted. [...]
> If the local parts match, the domain is checked in exactly the same way as for a pattern in a domain list"
>
> And then about domain lists:
> "If a pattern starts with an asterisk, the remaining characters of the pattern are compared with the terminating characters of the domain"
>
> Note: "start with". It does not say you can use an asterisk somewhere else.


The last "note" in your response above: No, the Exim Address Rewriting page listed this as an example:

> Right here is a similar example rewrite rule:
>
> 7. Rewriting examples
> Here is an example of the two common rewriting paradigms:
>
> *@*.hitch.fict.example


Two asterisk charters included in that example.

So are you saying that actually more than one asterisk is not actually allowed?

How, with what syntax, would it be possible to use to seek out portions of the email address to detect it is a local address in order to map to a public Internet email address? I am seeking to detect
the presence of either a specific server hostname or the presence of the subdomain our internal office computers utilize. If either of those are true, rewriting the email address to a public Internet
address is necessary.

It seems Internal emails may be generated with a variety of addresses, so I was trying to seek out address keywords which would indicate to Exim that "this is a local-only address, it needs to be
rewritten." Thus my list: 1) emails to root 2) internal server hostnames or 3) the subdomain our local computers use. So replying to Daniel, I feel it is a risk of missing emails that need to have
local addresses rewritten if I were to list out a mapping list of local to public Internet addresses. As example it seems local mail may be sent to just user or user@hostname or
user@hostname.subdomain.realdomain.com and I would rather not have to duplicate rules for each address format nuance possible.

I am thankful,

--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Difficulty getting Exim Address rewriting working on Ubuntu Linux [ In reply to ]
On Thu, 28 Dec 2023, Michael Lueck via Exim-users wrote:

>> Note: "start with". It does not say you can use an asterisk
>> somewhere else.
>
> The last "note" in your response above: No, the Exim Address
> Rewriting page listed this as an example:
>
>> Right here is a similar example rewrite rule:
>>
>> 7. Rewriting examples
>> Here is an example of the two common rewriting paradigms:
>>
>> *@*.hitch.fict.example
>
> Two asterisk charters included in that example.
>
> So are you saying that actually more than one asterisk is not
> actually allowed?

One asterix is allowed at the start of the username
and one at the start of the host/domainame.

--
Andrew C. Aitchison Kendal, UK
andrew@aitchison.me.uk

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Difficulty getting Exim Address rewriting working on Ubuntu Linux [ In reply to ]
Greetings Andrew,


Andrew C Aitchison wrote:
>
> One asterix is allowed at the start of the username
> and one at the start of the host/domainame.


Ahhh.... that was helpful!

So I adjusted the rewrite rules to be as follows:


begin rewrite
root@* realemailaddress@realdomain.com Eh
*@hostname realemailaddress@realdomain.com Eh
*@*.realdomain.com realemailaddress@realdomain.com Eh


And the results are much better testing with the Exim command line tool.

I appreciate the clarification very much!

I am thankful,

--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/