Re: [exim] Expanding $header_from

Pàgina inicial
Delete this message
Reply to this message
Autor: Phil Pennock
Data:  
A: Dean Brooks
CC: exim-users
Assumpte: Re: [exim] Expanding $header_from
On 2011-03-10 at 10:43 -0500, Dean Brooks wrote:
> On Thu, Mar 10, 2011 at 03:53:08PM +0100, Uros Meglic wrote:
> > if I got this right the $header_from expand into "Username <
> > username@???>". Is this right? Now how could get just <
> > username@???> out of this $header_from?
>
> The expansion of ${address:$h_from:} will give you what you are
> looking for. If you want it in all lower-case, you could even do
> ${lc:${address:$h_from:}}
>
> Now, this assumes that there is only a single address in the From:
> header, which is 99.9% of the time. Haven't tested it on what
> happens with multiple addresses in the header.


You get nothing.

To get the last:
${reduce{${addresses:$h_from:}}{}{$item}}
To get the first:
${reduce{${addresses:$h_from:}}{}{${if eq{$value}{}{$item}{$value}}}}

Alternatively, you can choose to reject messages with multiple addresses
in From: in your DATA ACL; you'll be rejecting messages that are
technically well-formed, but it's your system and you get to choose what
you accept (unless you have contracts with customers saying otherwise).

The easy way to test these things:

$ cat <<EOM > test.eml
From: Phil Pennock <phil@???>, Snert <snert@???>
To: Philip <philip@???>
Subject: Hey ho
Date: nowish

foo
EOM
$ exim -bem test.eml
> ${address:$h_to:}

philip@???
> ${address:$h_from:}


> ${addresses:$h_from:}

phil@???:snert@???
> ${reduce{${addresses:$h_from:}}{}{$item}}

snert@???
> ${reduce{${addresses:$h_from:}}{}{${if eq{$value}{}{$item}{$value}}}}

phil@???