简体   繁体   中英

How to set variable in procmail as To email address

I have a Procmail rule that uses formail to parse the To: email header to determine the email address the email was sent to:

TO_=`formail -XTo:`

This isn't working, as I'd like ${TO_} to evaluate to "address@domain.com", but what I'm getting is "To: firstName lastName".

How can I set an environment variable in a procmail script to the format I'd like?

No, you are extracting the full contents of the To: header, which should normally look something like Real Name <address@example.net> . There are many variations, though; it could also be address@example.net (Real Name) , for example, though this format is obsolescent.

If you know that the header contains the address between <brokets> , you can extract the text between them without using formail or another external utility.

:0
* ^To:.*<\/[^>]+
{ TO_=$MATCH }

This uses Procmail's special \/ extraction token which assigns the matching text after it into the special internal variable MATCH .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM