Re: [exim] Rewriting envelope from to header From

2017-07-13 Thread Frank Richter

Am 13.07.2017 um 00:50 schrieb Heiko Schlittermann via Exim-users:

Hi,

Frank Richter  (Mi 12 Jul 2017 15:46:31 CEST):
…

From: Frank Richter
I'd like to rewrite envelope from "apache@*.mydomain" to the address in
header From.
I tried it according to https://github.com/Exim/exim/wiki/Q0801 with this
rewrite rule:

apache@*.mydomain ${sg{$h_from:}{^.*<(.*)>}{\$1}}  Ffrs

seems complicated. Lena's approach is better (using the ${address:…}
operator.


Yes, thanks for this.

According to
https://www.exim.org/exim-html-current/doc/html/spec_html/ch-address_rewriting.html
(untested):

apache@*.mydomain ${address:$rh_from:} F

I suspect that the wiki page is wrong, but I'm not sure.

Unfortunately, this doesn't work either. Same error message:
Rewrite of apa...@hrz.tu-chemnitz.de yielded unparseable address: empty
address in address

I'm sendig with: swaks --to ...  --from apa...@hrz.tu-chemnitz.de --server
... --data  /tmp/mail

The rules from the rewrite section are applied at the time the
message is receveived (as written in the spec file). So, at the time
the envelope gets rewritten, the $h_from: isn't set yet.


Ok, that's true. So I guess, it should be added to 
https://github.com/Exim/exim/wiki/Q0801



Probably you need to rewrite at transport time. But … the envelope
sender can't be rewritten at transport time, transports have a
"return_path" option for modification of the envelope sender.


Your and Jeremy's and Jan's comments lead me to this:

begin transports
…
smtp:
  driver = smtp
  return_path = ${if and {{match {$return_path}{^apache@.*\.tu-chemnitz\.de\$}}\
  {match 
{${domain:${address:$h_from:}}}{.*\.tu-chemnitz\.de\$}}}\
{${address:$h_from:}}fail}

I tried some cases and abuse scenarios - it works as aspected: Rewrite 
Envelope From, if the header From: is a local address.

Would it be possible to check the domain with a defined domainlist?

But anyway, I'll try to expand the test to check, if header From: is a valid 
local address.


Many thanks,
Frank
Chemnitz University of Technology, Germany


smime.p7s
Description: S/MIME Cryptographic Signature
-- 
## List details at https://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/

Re: [exim] Rewriting envelope from to header From

2017-07-12 Thread Heiko Schlittermann via Exim-users
Hi,

Frank Richter  (Mi 12 Jul 2017 15:46:31 CEST):
…
> > > From: Frank Richter
> > > I'd like to rewrite envelope from "apache@*.mydomain" to the address in
> > > header From.
> > > I tried it according to https://github.com/Exim/exim/wiki/Q0801 with this
> > > rewrite rule:
> > > 
> > > apache@*.mydomain ${sg{$h_from:}{^.*<(.*)>}{\$1}}  Ffrs

seems complicated. Lena's approach is better (using the ${address:…}
operator.

> > According to
> > https://www.exim.org/exim-html-current/doc/html/spec_html/ch-address_rewriting.html
> > (untested):
> > 
> > apache@*.mydomain ${address:$rh_from:} F
> > 
> > I suspect that the wiki page is wrong, but I'm not sure.
> 
> Unfortunately, this doesn't work either. Same error message:
> Rewrite of apa...@hrz.tu-chemnitz.de yielded unparseable address: empty
> address in address
> 
> I'm sendig with: swaks --to ...  --from apa...@hrz.tu-chemnitz.de --server
> ... --data  /tmp/mail

The rules from the rewrite section are applied at the time the
message is receveived (as written in the spec file). So, at the time
the envelope gets rewritten, the $h_from: isn't set yet.

Probably you need to rewrite at transport time. But … the envelope
sender can't be rewritten at transport time, transports have a
"return_path" option for modification of the envelope sender.

[The usual disclaimer: I may be wrong, I didn'nt cross check with the
documentation.]

Best regards from Dresden/Germany
Viele Grüße aus Dresden
Heiko Schlittermann
-- 
 SCHLITTERMANN.de  internet & unix support -
 Heiko Schlittermann, Dipl.-Ing. (TU) - {fon,fax}: +49.351.802998{1,3} -
 gnupg encrypted messages are welcome --- key ID: F69376CE -
 ! key id 7CBF764A and 972EAC9F are revoked since 2015-01  -


signature.asc
Description: PGP signature
-- 
## List details at https://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/

Re: [exim] Rewriting envelope from to header From

2017-07-12 Thread Jan Ingvoldstad via Exim-users
On Wed, Jul 12, 2017 at 1:43 PM, Frank Richter
 wrote:
> My aim is that the envelope from  (Return-Path) is set to the header from
> (whatever it is) for some of our webservers, where PHP programmers send
> email, but don't set the envelope from, so that bounces will go to
> apache@mydomain. They should go to the header-From …

This is something you should avoid, unless you have very strict
control over what From addresses you permit.

In other words, you need to ensure that you have egress filtering of
From addresses for these cases. Please ensure, for your own sake, that
the From (or envelope-from!) addresses are restricted to domains under
your control, so that they won't contain e.g. Outlook-hosted e-mail
addresses.

Consider using SRS (sending rewrite scheme, see e.g.
https://github.com/Exim/exim/wiki/SRS) for rewriting the sender
address, and sure, use apache@mydomain as the base address for your
rewrites, so that you get e.g.
 as the envelope sender.
-- 
Jan

-- 
## List details at https://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/

Re: [exim] Rewriting envelope from to header From

2017-07-12 Thread Jeremy Harris
On 12/07/17 14:46, Frank Richter wrote:
>> apache@*.mydomain ${address:$rh_from:} F
>>
>> I suspect that the wiki page is wrong, but I'm not sure.
> 
> Unfortunately, this doesn't work either. Same error message:
> Rewrite of apa...@hrz.tu-chemnitz.de yielded unparseable address: empty
> address in address
> 
> I'm sendig with: swaks --to ...  --from apa...@hrz.tu-chemnitz.de
> --server ... --data  /tmp/mail
> 
> /tmp/mail contains  an e-mail with From:-Header.

What does running with "-d-all+expand+rewrite" show when you try that?

Separately, could you be using a transport "return_path" option rather
than a rewrite rule, since you're aiming at the envelope-from?
-- 
Cheers,
  Jeremy

-- 
## List details at https://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/


Re: [exim] Rewriting envelope from to header From

2017-07-12 Thread Frank Richter

From:  Lena--- via Exim-users:

From: Frank Richter
I'd like to rewrite envelope from "apache@*.mydomain" to the address in
header From.
I tried it according to https://github.com/Exim/exim/wiki/Q0801 with this
rewrite rule:

apache@*.mydomain ${sg{$h_from:}{^.*<(.*)>}{\$1}}  Ffrs

According to
https://www.exim.org/exim-html-current/doc/html/spec_html/ch-address_rewriting.html
(untested):

apache@*.mydomain ${address:$rh_from:} F

I suspect that the wiki page is wrong, but I'm not sure.


Unfortunately, this doesn't work either. Same error message:
Rewrite of apa...@hrz.tu-chemnitz.de yielded unparseable address: empty 
address in address


I'm sendig with: swaks --to ...  --from apa...@hrz.tu-chemnitz.de --server 
... --data  /tmp/mail


/tmp/mail contains  an e-mail with From:-Header.


Frank
Chemnitz University of Technology, Germany


smime.p7s
Description: S/MIME Cryptographic Signature
-- 
## List details at https://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/

Re: [exim] Rewriting envelope from to header From

2017-07-12 Thread Lena--- via Exim-users
> From: Frank Richter

> I'd like to rewrite envelope from "apache@*.mydomain" to the address in 
> header From.
> I tried it according to https://github.com/Exim/exim/wiki/Q0801 with this 
> rewrite rule:
> 
> apache@*.mydomain ${sg{$h_from:}{^.*<(.*)>}{\$1}}  Ffrs

According to
https://www.exim.org/exim-html-current/doc/html/spec_html/ch-address_rewriting.html
(untested):

apache@*.mydomain ${address:$rh_from:} F

I suspect that the wiki page is wrong, but I'm not sure.

-- 
## List details at https://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/


Re: [exim] Rewriting envelope from to header From

2017-07-12 Thread Mueller
So in my case, and taht is what I do with rewriting is:
Everyone,  who sends  emails with  @from.mylocaldom is rewritten to 
@to.myproviderdom according the listing in a special file.
Nearly the same as you want to do. This should  help to get it done.
*@tplk.loc "${extract{remote} 
{${lookup{$0}lsearch{/etc/exim/lokal_remote}{$value}fail}}{$value} fail}" rsfF

And the other way round. Eimails comming in ,set back to local domain:
^[a-z-0-9\.\-]+@(tropenklinik|gaestehaus-albblick)\.de "${extract{lokal} 
{${lookup{$0}lsearch{/etc/exim/remote_lokal}{$value}fail}}{$value} fail}" ST



EDV Daniel Müller

Leitung EDV
Tropenklinik Paul-Lechler-Krankenhaus
Paul-Lechler-Str. 24
72076 Tübingen 
Tel.: 07071/206-463, Fax: 07071/206-499
 Email: muel...@tropenklinik.de
 www.tropenklinik.de
 www.bauen-sie-mit.tropenklinik.de  

 





-Ursprüngliche Nachricht-
Von: Frank Richter [mailto:frank.rich...@hrz.tu-chemnitz.de] 
Gesendet: Mittwoch, 12. Juli 2017 13:44
An: exim-users@exim.org
Betreff: Re: [exim] Rewriting envelope from to header From

Am 12.07.2017 um 10:45 Mueller wrote:
> On the first glance:
>
> Just put a text-file in /etc/exim or where  exims path is linked to
> Ex.: rewrite
>
> In rewrite : apchache@your.mydomain : remote=apache@rewritten.mydomain  
> <-- first real then after remote what you want it to be In exim.conf:
>
> Rewrite Rules:
>
>
> ##mails out
> apache@your.mydomain "${extract{remote} 
> {${lookup{$0}lsearch{/etc/exim/rewrite}{$value}fail}}{$value} fail}" 
> rsfF
Seems to me a statical rewrite – that's not want I try to achieve.
My aim is that the envelope from  (Return-Path) is set to the header from 
(whatever it is) for some of our webservers, where PHP programmers send email, 
but don't set the envelope from, so that bounces will go to apache@mydomain. 
They should go to the header-From …

Frank
Chemnitz University of Technology, Germany

>
> -Ursprüngliche Nachricht-
> Von: Frank Richter [mailto:frank.rich...@hrz.tu-chemnitz.de]
> Gesendet: Mittwoch, 12. Juli 2017 09:22
> An: exim-users@exim.org
> Betreff: [exim] Rewriting envelope from to header From
>
> Hwllo,
>
> I'd like to rewrite envelope from "apache@*.mydomain" to the address in 
> header From.
> I tried it according to https://github.com/Exim/exim/wiki/Q0801 with this 
> rewrite rule:
>
> apache@*.mydomain ${sg{$h_from:}{^.*<(.*)>}{\$1}}  Ffrs
>
> Sending an email with a header From: leads to this:
>
> 2017-07-12 09:10:49 Rewrite of apache@sub.mydomain yielded unparseable 
> address: empty address in address
>
> I tried different variations of header From, and broke the rewrite 
> rule down to
>
> apache@*.mydomain $h_from: F
>
> with no success.
>
> Any ideas are welcome!
>
> Regards,
> Frank Richter
> Chemnitz University of Technology, Germany
>
>
>



-- 
## List details at https://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/

Re: [exim] Rewriting envelope from to header From

2017-07-12 Thread Frank Richter

Am 12.07.2017 um 10:45 Mueller wrote:

On the first glance:

Just put a text-file in /etc/exim or where  exims path is linked to
Ex.: rewrite

In rewrite : apchache@your.mydomain : remote=apache@rewritten.mydomain  <-- 
first real then after remote what you want it to be
In exim.conf:

Rewrite Rules:


##mails out
apache@your.mydomain "${extract{remote} 
{${lookup{$0}lsearch{/etc/exim/rewrite}{$value}fail}}{$value} fail}" rsfF

Seems to me a statical rewrite – that's not want I try to achieve.
My aim is that the envelope from  (Return-Path) is set to the header from 
(whatever it is) for some of our webservers, where PHP programmers send 
email, but don't set the envelope from, so that bounces will go to 
apache@mydomain. They should go to the header-From …


Frank
Chemnitz University of Technology, Germany



-Ursprüngliche Nachricht-
Von: Frank Richter [mailto:frank.rich...@hrz.tu-chemnitz.de]
Gesendet: Mittwoch, 12. Juli 2017 09:22
An: exim-users@exim.org
Betreff: [exim] Rewriting envelope from to header From

Hwllo,

I'd like to rewrite envelope from "apache@*.mydomain" to the address in header 
From.
I tried it according to https://github.com/Exim/exim/wiki/Q0801 with this 
rewrite rule:

apache@*.mydomain ${sg{$h_from:}{^.*<(.*)>}{\$1}}  Ffrs

Sending an email with a header From: leads to this:

2017-07-12 09:10:49 Rewrite of apache@sub.mydomain yielded unparseable address: 
empty address in address

I tried different variations of header From, and broke the rewrite rule down to

apache@*.mydomain $h_from: F

with no success.

Any ideas are welcome!

Regards,
Frank Richter
Chemnitz University of Technology, Germany







smime.p7s
Description: S/MIME Cryptographic Signature
-- 
## List details at https://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/

Re: [exim] Rewriting envelope from to header From

2017-07-12 Thread Mueller
On the first glance:

Just put a text-file in /etc/exim or where  exims path is linked to
Ex.: rewrite

In rewrite : apchache@your.mydomain : remote=apache@rewritten.mydomain  <-- 
first real then after remote what you want it to be 
In exim.conf:

Rewrite Rules:


##mails out
apache@your.mydomain "${extract{remote} 
{${lookup{$0}lsearch{/etc/exim/rewrite}{$value}fail}}{$value} fail}" rsfF


EDV Daniel Müller

Leitung EDV
Tropenklinik Paul-Lechler-Krankenhaus
Paul-Lechler-Str. 24
72076 Tübingen 
Tel.: 07071/206-463, Fax: 07071/206-499
 Email: muel...@tropenklinik.de
 www.tropenklinik.de
 www.bauen-sie-mit.tropenklinik.de  

 





-Ursprüngliche Nachricht-
Von: Frank Richter [mailto:frank.rich...@hrz.tu-chemnitz.de] 
Gesendet: Mittwoch, 12. Juli 2017 09:22
An: exim-users@exim.org
Betreff: [exim] Rewriting envelope from to header From

Hwllo,

I'd like to rewrite envelope from "apache@*.mydomain" to the address in header 
From.
I tried it according to https://github.com/Exim/exim/wiki/Q0801 with this 
rewrite rule:

apache@*.mydomain ${sg{$h_from:}{^.*<(.*)>}{\$1}}  Ffrs

Sending an email with a header From: leads to this:

2017-07-12 09:10:49 Rewrite of apache@sub.mydomain yielded unparseable address: 
empty address in address

I tried different variations of header From, and broke the rewrite rule down to

apache@*.mydomain $h_from: F

with no success.

Any ideas are welcome!

Regards,
Frank Richter
Chemnitz University of Technology, Germany



-- 
## List details at https://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] Rewriting envelope from to header From

2017-07-12 Thread Frank Richter

Hwllo,

I'd like to rewrite envelope from "apache@*.mydomain" to the address in 
header From.
I tried it according to https://github.com/Exim/exim/wiki/Q0801 with this 
rewrite rule:


apache@*.mydomain ${sg{$h_from:}{^.*<(.*)>}{\$1}}  Ffrs

Sending an email with a header From: leads to this:

2017-07-12 09:10:49 Rewrite of apache@sub.mydomain yielded unparseable address: 
empty address in address

I tried different variations of header From, and broke the rewrite rule down to

apache@*.mydomain $h_from: F

with no success.

Any ideas are welcome!

Regards,
Frank Richter
Chemnitz University of Technology, Germany



smime.p7s
Description: S/MIME Cryptographic Signature
-- 
## List details at https://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/