procmail
[Top] [All Lists]

Re: How To Extract.

2005-04-09 10:51:07
On 8 Apr 2005, at 19:55 :04, multimedia-fan(_at_)myrealbox(_dot_)com wrote:

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.

    # domain portion
    :0
    * CLEANFROM ?? @\/.*
    {
        FROM_DOMAIN=$MATCH
    }

## Get the domainpart of the email address, no subdomains.

hint: what you are looking for is (any number of not '.' characters, followed by a period, followed by any number of not '.''s followed by the end of the line.

Maybe something along the lines of:

        :0
        * FROM_DOMAIN ?? .*\/([^\.]+)\.([^\.]+)$
        { TOPD = $MATCH }

(tested, works)

--
#27794 <Vellius> ... I wonder if the really nerdy Klingons learn how to speak english


____________________________________________________________
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

<Prev in Thread] Current Thread [Next in Thread>