Ubuntu/Debian 上的 Sendmail smrsh 别名脚本管道问题

Ubuntu/Debian 上的 Sendmail smrsh 别名脚本管道问题

我已经为这个问题绞尽脑汁 2 周了。我试图将 sendmail 别名(虚拟域的 catchall)传送到 php 脚本。但是,我总是收到以下错误(无法直接向程序发送邮件):

10月7日 14:35:49 fut-02 sm-mta[14057]: o97LZlmh014057: <[电子邮件保护]>... 无法直接向程序发送邮件 10 月 7 日 14:35:49 fut-02 sm-mta[14057]: o97LZlmh014057: from=, size=0, class=0, nrcpts=0, proto=ESMTP, daemon=MTA-v4, reply=mail-ww0-f46.google.com [74.125.82.46]

我已经在 virtusers 文件中尝试了以下别名:

@domain.com "|php -q /home/myuser/myscript.php"
@domain.com "|/usr/bin/php5 -q /home/myuser/myscript.php"
@domain.com "|php5 /home/myuser/myscript.php"
@domain.com "|myscript.php"
@domain.com "|php5 myscript.php"

我尝试通过两种不同的方式在 sendmail.mc 文件中启用 smrsh:

FEATURE(`smrsh',`/usr/lib/sm.bin/smrsh')dnl
FEATURE(`smrsh')dnl

然后我尝试将 /usr/bin/php、/usr/bin/php5(实际二进制文件)和脚本本身链接到 /etc/mail/smrsh/。我还尝试完全禁用 smrsh。每次测试都会导致相同的错误。为了验证 smrsh 是否正常工作,我可以成功运行:

/usr/lib/sm.bin/smrsh -c "/usr/bin/php5 -q /home/user/myscript.php"

我的 sendmail.mc 的副本位于这篇文章的底部。

我是否遗漏了一些显而易见的东西?Ubuntu/Debian sendmail 配置中是否可能还有其他地方可以阻止向脚本发送邮件?

值得一提的是,我在 Ubuntu 10.10 RC 和 Debian 5 上尝试了这个设置。两者的结果相同,但 Debian 默认的 sendmail.mc 格式不正确(在 MAILER 指令后有 FEATURES)。

divert(0)dnl
#
#   Copyright (c) 1998-2005 Richard Nelson.  All Rights Reserved.
#
#  This file is used to configure Sendmail for use with Debian systems.
#
define(`_USE_ETC_MAIL_')dnl
include(`/usr/share/sendmail/cf/m4/cf.m4')dnl
VERSIONID(`$Id: sendmail.mc, v 8.14.3-9.2ubuntu1 2010-08-03 06:56:05 cowboy Exp $')
OSTYPE(`debian')dnl
DOMAIN(`debian-mta')dnl
dnl # Items controlled by /etc/mail/sendmail.conf - DO NOT TOUCH HERE
undefine(`confHOST_STATUS_DIRECTORY')dnl        #DAEMON_HOSTSTATS=
dnl # Items controlled by /etc/mail/sendmail.conf - DO NOT TOUCH HERE
dnl #
dnl # General defines
dnl #
dnl # SAFE_FILE_ENV: [undefined] If set, sendmail will do a chroot()
dnl #   into this directory before writing files.
dnl #   If *all* your user accounts are under /home then use that
dnl #   instead - it will prevent any writes outside of /home !
dnl #   define(`confSAFE_FILE_ENV',             `')dnl
dnl #
dnl # Daemon options - restrict to servicing LOCALHOST ONLY !!!
dnl # Remove `, Addr=' clauses to receive from any interface
dnl # If you want to support IPv6, switch the commented/uncommentd lines
dnl #
FEATURE(`no_default_msa')dnl
dnl DAEMON_OPTIONS(`Family=inet6, Name=MTA-v6, Port=smtp, Addr=::1')dnl
DAEMON_OPTIONS(`Family=inet,  Name=MTA-v4, Port=smtp')dnl
dnl DAEMON_OPTIONS(`Family=inet6, Name=MSP-v6, Port=submission, M=Ea, Addr=::1')dnl
DAEMON_OPTIONS(`Family=inet,  Name=MSP-v4, Port=submission, M=Ea')dnl
dnl #
dnl # Be somewhat anal in what we allow
dnl define(`confPRIVACY_FLAGS',dnl
dnl `needmailhelo,needexpnhelo,needvrfyhelo,restrictqrun,restrictexpand,nobodyreturn,authwarnings')dnl
dnl #
dnl # Define connection throttling and window length
define(`confCONNECTION_RATE_THROTTLE', `15')dnl
define(`confCONNECTION_RATE_WINDOW_SIZE',`10m')dnl
dnl #
dnl # Features
dnl #
dnl # use /etc/mail/local-host-names
FEATURE(`use_cw_file')dnl
dnl #
dnl # The access db is the basis for most of sendmail's checking
FEATURE(`access_db', , `skip')dnl
dnl #
dnl # The greet_pause feature stops some automail bots - but check the
dnl # provided access db for details on excluding localhosts...
FEATURE(`greet_pause', `1000')dnl 1 seconds
dnl #
dnl # Delay_checks allows sender<->recipient checking
FEATURE(`delay_checks', `friend', `n')dnl
dnl #
dnl # If we get too many bad recipients, slow things down...
define(`confBAD_RCPT_THROTTLE',`3')dnl
dnl #
dnl # Stop connections that overflow our concurrent and time connection rates
FEATURE(`conncontrol', `nodelay', `terminate')dnl
FEATURE(`ratecontrol', `nodelay', `terminate')dnl
dnl #
dnl # If you're on a dialup link, you should enable this - so sendmail
dnl # will not bring up the link (it will queue mail for later)
dnl define(`confCON_EXPENSIVE',`True')dnl
dnl #
dnl # Dialup/LAN connection overrides
dnl #
include(`/etc/mail/m4/dialup.m4')dnl
include(`/etc/mail/m4/provider.m4')dnl
dnl #
dnl # Default Mailer setup
FEATURE(`smrsh',`/usr/lib/sm.bin/smrsh')dnl
FEATURE(`virtusertable', `hash /etc/mail/virtusers')dnl
VIRTUSER_DOMAIN_FILE(`/etc/mail/virtdomains')dnl
MAILER_DEFINITIONS
MAILER(`local')dnl
MAILER(`smtp')dnl

答案1

您必须修改规则集 0(或规则集 2)才能解决此问题:

LOCAL_RULE_0
R$* < @ virtualdomain.com. > $*     $#prog $: $1 @ virtualdomain.com

“蝙蝠书”(第 4 版)第 727 页讨论了程序传送代理。

上述方法不适用于 smrsh。它假设 $#prog 设置为一个程序,该程序根据其参数决定采取什么操作。

您甚至可以定义自己的交付代理,它将完全按照您的要求执行操作,而不是尝试适应现有情况。

答案2

据我所知,您需要在 virtusertable 中指定用户或别名,而不是管道。完成后,在别名文件中指定管道就可以了。

例如,在 /etc/mail/virtusers 中

@example.com pipeuser

然后在 /etc/aliases

pipeuser:“| /usr/bin/php5 -q /home/myuser/myscript.php”

相关内容