[英]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: 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".这不起作用,因为我希望${TO_}
评估为“address@domain.com”,但我得到的是“To:firstName lastName”。
How can I set an environment variable in a procmail script to the format I'd like?如何将 procmail 脚本中的环境变量设置为我想要的格式?
No, you are extracting the full contents of the To:
header, which should normally look something like Real Name <address@example.net>
.不,您正在提取To:
header 的全部内容,通常看起来应该类似于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.例如,它也可以是address@example.net (Real Name)
,尽管这种格式已经过时。
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.如果您知道 header 包含<brokets>
之间的地址,则可以在不使用formail
或其他外部实用程序的情况下提取它们之间的文本。
:0
* ^To:.*<\/[^>]+
{ TO_=$MATCH }
This uses Procmail's special \/
extraction token which assigns the matching text after it into the special internal variable MATCH
.这使用 Procmail 的特殊\/
提取标记,它将匹配的文本分配到特殊的内部变量MATCH
之后。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.