Re: [exim] Smarthost condition by h_From header variable

Pàgina inicial
Delete this message
Reply to this message
Autor: Gallai János
Data:  
A: exim-users
Assumpte: Re: [exim] Smarthost condition by h_From header variable
Dear Heiko,

I've tried envelope_sender but Exim says unknow variable.

The goal is: We would like to use a separate smarthost for specified
domains on real sender ( envelope_sender ) which is in the From: header.

For example: many users use webmail where the sender is www@???,
the real sender is user@???. There is no problem with MUAs
but webmail users always send mail with sender www@??? so the
real sender is in the From: header. I need to get this address somehow.

If I try this:

smarthost:
driver = manualroute
debug_print = Domain: From: ${local_part}@${domain}, Sender: $header_From
domains = ! pgsql;SELECT nev FROM domain WHERE nev =
'${quote_pgsql:$domain}' AND local = 1
condition = ${if match_domain{${domain:$h_From:}}{domain.com}{yes}{no}}
transport = remote_smtp
route_data = XXX.XXX.XXX.XXX
no_verify
no_more

It seems it works well. When $h_From is 'domain.com' it send to
smarthost if not it doesn't sends to smarthost but uses direct smtp.

But with an SQL it always calls smarthost router:

smarthost:
driver = manualroute
debug_print = Domain: From: ${local_part}@${domain}, Sender: $header_From
domains = ! pgsql;SELECT nev FROM domain WHERE nev =
'${quote_pgsql:$domain}' AND local = 1
condition = ${if match_domain{${domain:$h_From:}}{lookup pgsql{SELECT
nev FROM domain WHERE nev = '${domain:$h_From:}' AND relay = 1}{yes}{no}}}
transport = remote_smtp
route_data = XXX.XXX.XXX.XXX
no_verify
no_more

If I run the SQL-query manually it works fine: gives me back that expected.

I understand that I do something wrong but what?

Thanks,

János





2018-06-21 13:27 keltezéssel, Heiko Schlittermann via Exim-users írta:
> Hi,
>
> Gallai János via Exim-users <exim-users@???> (Do 21 Jun 2018 08:34:39 CEST):
>> Dear Users,
>>
>> I am trying to create a smarthost manualroute route depending on From:
>> header. Here is my router:
>>
>> smarthost:
>>    driver = manualroute
>>    domains = ! +local_domains
>>    condition = ${if eq{${domain:$h_From:}}{domain.com}}
>>    transport = remote_smtp
>>    route_data = XXX.XXX.XXX.XXX
>>    no_more

>>
>> What have I done wrong? Why is $h_From: variable empty in manualroute
>> driver?
>>
>> How to make a correct condition to check the From header?
> Depends on when the router is run.
>
> If you call the router implicitly from the ACL (require verify =
> recipient, … or similiar) there is hot header yet.
>
> If you test the router using `exim -bt …` it won't work, for the same
> reason, as there is no header yet.
>
> Better router testing you can do using Exim's -N option and a
> handcrafted message.
>
> If the message is received already, the header is set and the router
> should work.
>
>      Best regards from Dresden/Germany
>      Viele Grüße aus Dresden
>      Heiko Schlittermann

>
>