How do you extract the top level domain name from the sender's email
address?
For example
From: "Firstname Lastname" <username(_at_)subdomain(_dot_)address(_dot_)com>
I would like to match the address.com info a variable.
I have tried the following(some with the help of the archives and from
Sean's sandbox recommendations):
# Extracting the domain part from the headers.
# get the From: address as an address component ONLY (no comments)
:0 h
CLEANFROM=|formail -IReply-To: -rtzxTo:
# username portion
:0
* CLEANFROM ?? ^\/[^(_at_)]+
{
FROM_USER=$MATCH
}
# domain portion
:0
* CLEANFROM ?? @\/.*
{
FROM_DOMAIN=$MATCH
}
## Get the domainpart of the email address, no subdomains.
# domain portion
:0
* FROM_DOMAIN ?? \/()\..*\.[a-z][a-z]+$
{
DOMAIN=$MATCH
}
I tested \..*\.[a-z][a-z]+$ in Regexp coach and it matched the exact
thing that I was looking for.
Now, if I log DOMAIN's value, the sandbox log has the following.
procmail: No match on "\/()\..*\.[a-z][a-z]+$"
procmail: Assigning "DOMAIN="
:0 h
DOMAIN=| formail -x"From:" | egrep -iE \..*\.[a-z][a-z]+$
And got the same results.
Clearly procmail is not understanding the regular expression that I am
using.
Any suggestions on how to approach this.
If anyone can help, it would be appreciated, as always.
Thank you.
____________________________________________________________
procmail mailing list Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail