Sendmail smrsh在Ubuntu / Debian上别名脚本pipe道问题

我一直在对这个问题进行了两个星期的抨击。 我正在尝试做的是将一个sendmail别名(一个虚拟域的catchall)传递给一个php脚本。 但是,我总是得到以下错误(不能直接邮寄给程序):

Oct 7 14:35:49 fut-02 sm-mta [14057]:o97LZlmh014057:<[email protected]> …不能直接邮寄给程序Oct 7 14:35:49 fut-02 sm-mta [ 14057]:o97LZlmh014057:from =,size = 0,class = 0,nrcpts = 0,proto = ESMTP,daemon = MTA-v4,relay = 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 2种不同的方式:

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

然后,我尝试链接/ usr / bin / php,/ usr / bin / php5(实际的二进制文件),并将脚本本身链接到/ etc / mail / smrsh /。 我也尝试完全禁用smrsh。 每个testing都会导致相同的错误。 要validationsmrsh正在工作,我能够成功运行:

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

我的sendmail.mc的一个副本是在这篇文章的底部。

我错过了什么明显的? 在Ubuntu / Debian的sendmailconfiguration中是否还有其他地方可以阻止邮件发送到脚本?

FWIW,我在Ubuntu 10.10 RC和Debian 5上试过这个设置。除了Debian默认的sendmail.mc格式不正确(在MAILER指令之后有特性)之外,结果都一样。

 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 

您必须修改规则集0(或规则集2)来解决这个问题:

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

前传送代理在“蝙蝠书”(第4版)的第727页讨论。

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

你甚至可以定义你自己的送货代理,这将做你想要的,而不是试图适应你的情况。

AFAIK你需要在你的virtusertable中指定一个用户或别名,而不是pipe道。 一旦你这样做了,在你的别名文件中指定pipe道应该做的伎俩。

例如,在/ etc / mail / virtusers中

@ example.com pipeuser

然后在/ etc / aliases中

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