[Pkg-exim4-users] How to choose a smarthost based on From: address in Exim4

Martin Reising mreising+eximusers at nixhier.org
Mon Apr 3 10:17:37 BST 2023


On Sun, Apr 02, 2023 at 12:16:13PM +0530, Faheem Mitha via Pkg-exim4-users wrote:
> 
> My modified version of the solution by Auslander is
> 
>     dc_smarthost='"${if match{${lc:$header_from:}}{.*gmail.com}{smtp.gmail.com::587}{${if match{${lc:$header_from:}}{.*mydomain|.*mailbox.org}{smtp.mailbox.org::587}{secure-email-32.luxsci.com::587}}}}"'
> 
> This amounts to the pseudocode
> 
>     if the from header matches the regex .*gmail.com
>         then
>             use smtp.gmail.com::587
>     else if the from header matches .*mydomain|.*mailbox.org
>         then
>             use smtp.mailbox.org::587
>     else # default if nothing else matches
>             use secure-email-32.luxsci.com::587
> 

This is wrong, AFAIK:

      {${if match{${lc:$header_from:}}{.*mydomain|.*mailbox.org}


The String expansions documentation only show 'and' and 'or'

https://www.exim.org/exim-html-current/doc/html/spec_html/ch-string_expansions.html#vi268

Chapter 11 - String expansions
 8. Combining expansion conditions

 ${if or {{eq{$local_part}{spqr}} {eq{$domain}{testing.com}}} .... }
 
So '|' must be rewritten with 'or' (the following is untested): 

${if or 
      {match{${lc:$header_from:}} {.*mydomain}}
      {match{${lc:$header_from:}} {.*mailbox.org}}
.
.
.
}



More information about the Pkg-exim4-users mailing list