procmail
[Top] [All Lists]

Re: Extracting substring from formail -rzx "To:"

2004-06-29 23:58:45
Lee Hoffner wrote:

Upon achieving a match, I have a line in my recipe that extracts the sender's address and stores it to pass of to a PERL script. The problem is,
ADDRESS=`formail -rzx "To:"`
sometimes returns a proper name before the email address. (Example from procmail log: Assigning "ADDRESS="Jim Bernardi" <jbernardi(_at_)23skidoo(_dot_)net>"). This is tripping up the perl script, which is matching $ADDRESS to a MySQL db that contains only email addresses without names.

How can I ensure that ADDRESS contains only the email address, losing any proper name that might be in front of it?
CPAN has a Mail::Address module that extracts email addresses (or specific parts, if needed) from an SMTP header. If your mail server provides recipient information in another header as well, like X-Envelope-To or Delivered-To, matching on those may be an alternative also.

--
Klaus Johannes Rusch
KlausRusch(_at_)atmedia(_dot_)net
http://www.atmedia.net/KlausRusch/


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