问题

问题

问题

简而言之,在我的 Exim 传输中使用以下行不会导致TESTVAR环境变量的字符串扩展(插入):

headers_add = "X-TESTVAR: ${env{TESTVAR}{$value}{The TESTVAR environment variable was not found}}"

我从来没有得到过$value;我总是得到“未找到 TESTVAR 环境变量”。

我究竟做错了什么?


环境:

[email protected] [~]# cat /etc/redhat-release
CentOS release 6.10 (Final)

Exim 版本:

[email protected] [~]# exim --version
Exim version 4.91 #1 built 11-May-2018 09:49:25
Copyright (c) University of Cambridge, 1995 - 2018
(c) The Exim Maintainers and contributors in ACKNOWLEDGMENTS file, 2007 - 2018
Berkeley DB: Berkeley DB 4.7.25: (September 12, 2013)
Support for: crypteq iconv() IPv6 PAM Perl OpenSSL Content_Scanning DKIM DNSSEC Event I18N OCSP PRDR SPF Experimental_SRS
Lookups (built-in): lsearch wildlsearch nwildlsearch iplsearch dbm dbmjz dbmnz dnsdb passwd sqlite
Authenticators: cram_md5 dovecot plaintext spa
Routers: accept dnslookup ipliteral manualroute queryprogram redirect
Transports: appendfile/maildir autoreply lmtp pipe smtp
Malware: f-protd f-prot6d drweb fsecure sophie clamd avast sock cmdline
Configure owner: 0:0
Size of off_t: 8
2019-03-08 19:04:22 cwd=/home/account 2 args: exim --version
Configuration file is /etc/exim.conf

来自我的 exim.conf 的相关传输:

dovecot_virtual_delivery:
  driver = lmtp
  socket = /var/run/dovecot/lmtp
  batch_max = 200
  rcpt_include_affixes
  delivery_date_add
  envelope_to_add
  return_path_add
  headers_add = "X-TESTVAR: ${env{TESTVAR}{$value}{The TESTVAR environment variable was not found}}"

我执行的发送电子邮件的命令:

[email protected] [~]# export TESTVAR=hello
[email protected] [~]# echo $TESTVAR
hello
[email protected] [~]# exim -t
to:[email protected]
Hi there, this email should have a header named "X-TESTVAR" and it should have a value of "hello".
[email protected] [~]# 

生成的电子邮件:

Return-Path: <[email protected]>
Delivered-To: [email protected]
Received: from host.example.com
    by host.example.com with LMTP id IH+3MCUQg1waLwAAx771+g
    for <[email protected]>; Fri, 08 Mar 2019 19:00:21 -0600
Return-path: <[email protected]>
Envelope-to: [email protected]
Delivery-date: Fri, 08 Mar 2019 19:00:21 -0600
Received: from account by host.example.com with local (Exim 4.91)
    (envelope-from <[email protected]>)
    id 1h2QLV-0004Mo-Ee
    for [email protected]; Fri, 08 Mar 2019 19:00:21 -0600
to:[email protected]
Message-Id: <[email protected]>
From: [email protected]
Date: Fri, 08 Mar 2019 19:00:20 -0600
X-TESTVAR: The TESTVAR environment variable was not found

Hi there, this email should have a header named "X-TESTVAR" and it should have a value of "hello".

答案1

您正在寻找keep_environment设置。它指定哪些环境变量是受信任的,并且应该允许在 Exim 的执行中使用。(文档

如果你exim.conf包含这一行:

keep_environment = X-SOURCE : X-SOURCE-ARGS : X-SOURCE-DIR

将其更改为:

keep_environment = X-SOURCE : X-SOURCE-ARGS : X-SOURCE-DIR : TESTVAR

相关内容