procmail
[Top] [All Lists]

Re: get email address from the body of the email

2007-05-14 13:54:17
On 5/14/07, Alex Kosach <alex(_dot_)kosach(_at_)replacements(_dot_)com> wrote:

I am working on new procmail recipe that should find an email address in the
body of the email and assign it to a variable.

Would it be possible to use procmail's native language to get this email
address without using grep or egrep commands?

Grab http://www.well.com/user/barts/email/rfc822.txt and put it
somewhere from which your procmailrc can read it.  Then try something
like this:

INCLUDERC=rfc822.txt
:0
* $ B ?? ()\/$addrspec__
{ EMAIL_ADDRESS=$MATCH }

The double trailing underscores are a convention used by rfc822.txt so
that the variables it creates won't conflict with other variables in
your procmailrc.

This will copy the first thing in the message body that looks like an
email address, into the environment variable $EMAIL_ADDRESS.  Replace
the () above with an appropriate regular expression to narrow down the
context in which the address might be found.

If you know the local-part but not the domain, you can use

* $ B ?? ()\/knownlocal(_at_)$domain__

If instead you know the domain, use

* $ B ?? ()\/$localpart__(_at_)knowndomain\(_dot_)com

____________________________________________________________
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>