Discussion:
Extract email address from From header
(too old to reply)
Stephen Gran
2010-10-29 00:53:52 UTC
Permalink
Hello All!
I need to extract the email address From the from header and then use
that variable in a condition. I assume there is a way to set the
acl_c0 variable the result of a regular expression that can pull the
email address out from the From header.
$h_from in the data acl. No need for a regex and a custom variable.

Cheers,
--
--------------------------------------------------------------------------
| Stephen Gran | A violent man will die a violent death. |
| ***@lobefin.net | -- Lao Tsu |
| http://www.lobefin.net/~steve | |
--------------------------------------------------------------------------
--
## List details at http://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/
Elliot Murdock
2010-10-29 01:19:18 UTC
Permalink
Hello!

Thank you.

However, the $header_From variable returns not only the email address
but any names associated with it. For example,
From: John Doe <***@example.com> gives John Doe <***@example.com>

I would need a regex to extract the email address.

--Elliot
--
## List details at http://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/
James Price
2010-10-29 01:29:11 UTC
Permalink
Hello All!
I need to extract the email address From the from header and then use
that variable in a condition. I assume there is a way to set the
acl_c0 variable the result of a regular expression that can pull the
email address out from the From header.
Thanks,
Elliot
Try $sender_address should work in most cases.

Thanks,
James
--
## List details at http://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/
Elliot Murdock
2010-10-30 16:26:29 UTC
Permalink
Hello!

I've managed to use the set command to give acl_c) the value of the
email address in From header but putting this line in the acl:

set acl_c0 = ${if
match{$header_From:}{\([a-z,A-Z,\\.,\\-]+@[a-z,A-Z,\\.,\\-]+\)}{$1}}

However, I guess using the ${addresses} expansion operator would be
more conventional.

--Elliot
--
## List details at http://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/
Loading...