简体   繁体   English

Procmail 内容作为 POST 变量

[英]Procmail content as POST variable

Procmail should send my emails with the content to my api. Procmail 应该将包含内容的电子邮件发送到我的 api。 No matter what I try, I get the subject etc., but I can't get to the content.无论我尝试什么,我都知道主题等,但我无法进入内容。 The $CONTENT variable is filled with the subject. $CONTENT 变量用主题填充。

:0
{
 :0 w
  | CONTENT= cat

 :0
 | URL=$(curl -d  "content=$CONTENT" -d "title=Logged Activity" https://myapi.de/fetch.php);

}

You have a repeated syntax error;您有重复的语法错误;

:0 w
| CONTENT= cat

means assign an empty string to CONTENT for the duration of the cat command.意味着在cat命令的持续时间内为CONTENT分配一个空字符串。 I guess your intent is to assign the message's contents to the variable.我猜您的意图是将消息的内容分配给变量。 The syntax for that would be语法是

CONTENT=| cat    

(not a recipe, so no :0 w is useful, necessary, or correct here); (不是食谱,所以这里没有:0 w是有用的、必要的或正确的); but if you don't use this variable for anything else, there really is no need to assign it separately.但是如果您不将此变量用于其他任何事情,则确实没有必要单独分配它。

:0
| URL=$(curl -d  "content=$(cat)" -d "title=Logged Activity" https://myapi.de/fetch.php);

As above, this also probably doesn't do what you actually want.如上所述,这也可能无法满足您的实际需求。 If you expect the variable to be assigned within your .procmailrc , try如果您希望在.procmailrc分配变量,请尝试

URL=|curl -d "content=$(cat)" -d "title=Logged Activity" https://myapi.de/fetch.php;

The trailing semicolon (or some other character from SHELLMETAS ) is required to force Procmail to run the subprocess in a shell (otherwise it would pass through the literal string content=$(cat) as the value of the option -d ).需要尾随分号(或来自SHELLMETAS其他字符)来强制 Procmail 在 shell 中运行子SHELLMETAS (否则它将通过文字字符串content=$(cat)作为选项-d的值)。

In some more detail, the recipe更详细地说,配方

:0
| variable=$(cat)

would run a shell as a subprocess, and assign the message's contents as the value of the shell variable variable , but then immediately exit, which of course loses any effects of variable assignments which happened within that subprocess.将外壳作为子进程运行,并将消息的内容分配为外壳变量variable ,但随后立即退出,这当然会失去在该子进程中发生的变量分配的任何影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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