我正在使用 Exim 并创建了一个可以正常接收和发送电子邮件的邮件服务器。现在,我想为每封收到的电子邮件启用 SPF 检查,以便为Received SPF
这些电子邮件添加标题。但我似乎不知道该怎么做。
医生说,SPF verification support is built into Exim if SUPPORT_SPF=yes is set in Local/Makefile. The support uses the libspf2 library https://www.libspf2.org/.
但我认为,只有从源代码构建 Exim 时,才能将此选项设置为是。我直接从 ubuntu 包安装了它(我想 libspf2 是自动安装的),但不知道它的位置在哪里Local/Makefile
。我很确定这可以很容易地完成,但我现在对此一无所知。
30_exim4-config_check_rcpt
我还检查了 Exim 配置目录,并在文件中发现了以下相关代码。
spf-tools-perl
这清楚地表明,如果启用并安装了SPF 检查,Exim 将在 RCPT 命令后检查发件人的 SPF 记录。我安装了spf-tools-perl
,但仍然没有看到任何Received SPF
标头。因此,这引出了两个问题。
- 如何启用 SPF 检查以允许执行此代码?
- 为什么是 spf-tools-perl,因为文档中明确指出 Exim 使用 libspf。那么为什么要使用两个库呢?
# Use spfquery to perform a pair of SPF checks.
#
# This is quite costly in terms of DNS lookups (~6 lookups per mail). Do not
# enable if that's an issue. Also note that if you enable this, you must
# install "spf-tools-perl" which provides the spfquery command.
# Missing spf-tools-perl will trigger the "Unexpected error in
# SPF check" warning.
.ifdef CHECK_RCPT_SPF
deny
message = [SPF] $sender_host_address is not allowed to send mail from \
${if def:sender_address_domain {$sender_address_domain}{$sender_helo_name}}.
log_message = SPF check failed.
!acl = acl_local_deny_exceptions
condition = ${run{/usr/bin/spfquery.mail-spf-perl --ip \
${quote:$sender_host_address} --identity \
${if def:sender_address_domain \
{--scope mfrom --identity ${quote:$sender_address}}\
{--scope helo --identity ${quote:$sender_helo_name}}}}\
{no}{${if eq {$runrc}{1}{yes}{no}}}}
defer
message = Temporary DNS error while checking SPF record. Try again later.
!acl = acl_local_deny_exceptions
condition = ${if eq {$runrc}{5}{yes}{no}}
warn
condition = ${if <={$runrc}{6}{yes}{no}}
add_header = Received-SPF: ${if eq {$runrc}{0}{pass}\
{${if eq {$runrc}{2}{softfail}\
{${if eq {$runrc}{3}{neutral}\
{${if eq {$runrc}{4}{permerror}\
{${if eq {$runrc}{6}{none}{error}}}}}}}}}\
} client-ip=$sender_host_address; \
${if def:sender_address_domain \
{envelope-from=${sender_address}; }{}}\
helo=$sender_helo_name
warn
log_message = Unexpected error in SPF check.
condition = ${if >{$runrc}{6}{yes}{no}}
.endif```