我需要为一个testing环境build立一个邮件服务器configuration,它可以接受所有的邮件(即所有的用户和所有的域名,甚至是非本地的邮件),并把它放到一个本地的邮箱中。
我所拥有的是带有Sendmail(8.14)的SLES 11,我尝试修改/ etc / mail / virtusertable看起来像
@ catchall
或者像
@* catchall
但是没有用的目标邮件地址(例如“[email protected]” )不会被重写为catchall @ ,因此会尝试传送给相应的MX:
# sendmail -bt ADDRESS TEST MODE (ruleset 3 NOT automatically invoked) Enter <ruleset> <address> > 3,0 [email protected] canonify input: santa @ northpole . org Canonify2 input: santa < @ northpole . org > Canonify2 returns: santa < @ northpole . org . > canonify returns: santa < @ northpole . org . > parse input: santa < @ northpole . org . > Parse0 input: santa < @ northpole . org . > Parse0 returns: santa < @ northpole . org . > ParseLocal input: santa < @ northpole . org . > ParseLocal returns: santa < @ northpole . org . > Parse1 input: santa < @ northpole . org . > MailerToTriple input: < > santa < @ northpole . org . > MailerToTriple returns: santa < @ northpole . org . > Parse1 returns: $# esmtp $@ northpole . org . $: santa < @ northpole . org . > parse returns: $# esmtp $@ northpole . org . $: santa < @ northpole . org . >
似乎通配符在查找表的源域部分中不受支持。
我将如何与Sendmail实现这个?
编辑:根据Andrzej的评论,我已经尝试了mailertable条目
. local:catch-all-outgoing
以及
.. local:catch-all-outgoing
并且在两种情况下都接收到相同的sendmail -bv输出:
# sendmail -d60.5 -bv [email protected] map_lookup(dequote, root, %0=root) => NOT FOUND (0) map_lookup(host, example.net, %0=example.net) => example.net. (0) [email protected]... deliverable: mailer esmtp, host example.net., user [email protected]
( 是的,根,因为sendmail似乎无法作为非根运行 )
编辑:事实certificate,macros文件中没有启用mailertablefunction,因此sendmail.cf没有包含适当的重写规则以使其工作。
你在这里遇到什么: /etc/mail/virtusertable我相信仅限于入站电子邮件,而不是出站。
您可以在mailertable或SMART_HOST中使用默认路由将所有非本地消息传递到一个本地邮箱/别名。
mailertable entry: . local:catch-all-outgoing aliases: catch-all-outgoing: some-local-account
任何不以点开头的LHS条目都与指定的完整主机名相匹配。 以点开头的LHS条目与该域名(包括前导点)的任何内容匹配 – 也就是说,它们可以被认为具有用于非空字符序列的前导“。+”正则expression式模式。
RHS应该始终是一个“邮件:主机”对。 邮件程序是邮件程序的configuration名称(即sendmail.cf文件中的M行)。 “主机”将是传递给该邮件的主机名。
(参考: sendmail自述文件 ,“使用MAILERTABLES”部分)
所以像这样:
. local:catch-all-outgoing 在/ etc / mail / mailertable中, . local:catch-all-outgoing (根据Adrzej的注释只是一个点)应该使任何domain.tldredirect到sendmail.cf中定义的本地邮件configuration。 使用别名捕获catch-all-outgoing的主机名,并使其成为本地电子邮件地址。
为了mailertable工作,它需要在configuration中启用。 添加
FEATURE(`mailertable',`hash -o /etc/mail/mailertable.db')dnl
到生成你的configuration的m4macros文件应该照顾。
另外从sendmail站点的帮助文件:
的mailertable:
包括一个“邮件表”,可用于覆盖特定域(不在类{w}中,即本地主机名)的路由。 特征的论点可能是关键的定义。 如果没有指定,则使用的定义是:
哈希/ etc / mail / mailertable
此数据库中的密钥是完全限定的域名或以点开头的部分域 – 例如“vangogh.CS.Berkeley.EDU”或“.CS.Berkeley.EDU”。 作为后者的特例,“。” 匹配未被其他密钥覆盖的任何域。 值的格式必须是:mailer:domain
其中“邮件程序”是内部邮件的名称,“域”是发送邮件的地方。 这些地图不会反映到邮件标题中。 作为特殊情况,表单local:用户将使用本地邮件转发给指定的用户,
您可以为非本地域定义SMART_HOST ,为本地电子邮件域定义SMART_HOST 。
sendmail.mc:
define(`SMART_HOST',`local:some_existing_user')dnl define(`MAIL_HUB',`local:some_existing_user')dnl dnl optional part to list local users/mailboxes excluded from the redirect dnl in /etc/mail/direct-users file (one user per line) LOCAL_CONFIG FL/etc/mail/direct-users divert(0)
PS
使用echo '$=w' | sendmail -bt echo '$=w' | sendmail -bt获取本地电子邮件域名列表。 Sendmail默认情况下会自动填充它。
mailertable可能被用来从redirect中排除一些外部域
example.net %0