Ubuntu

Ubuntu/Debian 上的 Sendmail smrsh 別名腳本管道問題

  • May 1, 2011

兩週來,我一直在努力解決這個問題。我想要做的是將 sendmail 別名(虛擬域的集合)傳遞給 php 腳本。但是,我總是收到以下錯誤(無法直接郵寄給程序):

10 月 7 日 14:35:49 fut-02 sm-mta

$$ 14057 $$: o97LZlmh014057: <5minutes@dev2.domain.com> … 無法直接向程序發送郵件 10 月 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 有兩種不同的方式:

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 配置中是否有其他地方可以阻止向腳本發送郵件?

FWIW,我在 Ubuntu 10.10 RC 和 Debian 5 上嘗試了這個設置。除了 Debians 預設 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&lt;-&gt;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$* &lt; @ virtualdomain.com. &gt; $*     $#prog $: $1 @ virtualdomain.com

prog 傳遞代理在“bat book”(第 4 版)的第 727 頁進行了討論。

以上不適用於 smrsh。它假設 $#prog 被設置為一個程序,該程序根據其參數決定採取什麼行動。

您甚至可以定義自己的送貨代理,它會完全按照您的意願行事,而不是試圖適應您的情況。

引用自:https://serverfault.com/questions/189104