安全、快速且易于使用,这是我首选的 MTA(邮件传输代理)。
目前,没有任何发行版预装了 qmail。我们将专注于编译和安装 qmail,因为这是唯一棘手的部分:配置非常简单。
访问 www.qmail.org 下载最新版本。
然后运行以下命令解压缩它
mv qmail.tar.gz /usr/local/src
cd /usr/local/src ; tar -zxvf qmail.tar.gz
如果您找到 bz2 版本(更新且更好的压缩格式),只需将 tar 替换为
bunzip2 qmail.tar.bz2
tar -xvf qmail.tar
现在进入 qmail 目录以检查默认配置
cd qmail; more conf-*
您应该不需要更改任何默认设置,但您可以(例如)指定备用安装目录或更好的编译标志。
现在运行
mkdir /var/qmail
以创建目标目录。如果您尚未安装 Debian 发行版,则需要为 qmail 的使用添加多个用户 ID:qmail 的高安全性取决于此。
qmail 被划分为多个模块,每个模块都在自己的 UID 下运行,这使得入侵者更难破坏您的整个邮件系统或通过滥用它来获得 root 访问权限。
所以运行
# groupadd nofiles
# useradd -g nofiles -d /var/qmail/alias alias
# useradd -g nofiles -d /var/qmail qmaild
# useradd -g nofiles -d /var/qmail qmaill
# useradd -g nofiles -d /var/qmail qmailp
# groupadd qmail
# useradd -g qmail -d /var/qmail qmailq
# useradd -g qmail -d /var/qmail qmailr
# useradd -g qmail -d /var/qmail qmails
或者手动编辑 /etc/passwd
和 /etc/group
以自行添加这些用户。
Evan E. 报告说,对于 vanilla groupadd (Caldera 1.2),他必须使用“-g groupid”参数,否则 groupadd 会报告此错误:“具有该名称的组已存在。”
例如,您可以分别添加
qmail:*:2107:
nofiles:*:2108:
&
alias:*:7790:2108::/var/qmail/alias:/bin/true
qmaild:*:7791:2108::/var/qmail:/bin/true
qmaill:*:7792:2108::/var/qmail:/bin/true
qmailp:*:7793:2108::/var/qmail:/bin/true
qmailq:*:7794:2107::/var/qmail:/bin/true
qmailr:*:7795:2107::/var/qmail:/bin/true
qmails:*:7796:2107::/var/qmail:/bin/true
现在您可以运行
make setup check
以检查您的配置,然后
./config
以配置 qmail。注意,您的服务器必须可以通过 DNS 解析,否则 ./config 将会混淆。
如果您没有 DNS 访问权限,您可以直接通过以下方式提供您的服务器名称
./config-fast foo.bar.com
现在您必须安装一些别名,因为除非您编译并安装可选软件包,否则 qmail 不会使用 /etc/alias。
这是我的设置
File : ".qmail-MAILER-DAEMON"
&postmaster
File : ".qmail-bin"
&root
File : ".qmail-daemon"
&root
File : ".qmail-decode"
&root
File : ".qmail-dumper"
&root
File : ".qmail-games"
&root
File : ".qmail-ingres"
&root
File : ".qmail-mailer-daemon"
&postmaster
File : ".qmail-manager"
&root
File : ".qmail-news"
&root
File : ".qmail-nobody"
&root
File : ".qmail-operator"
&root
File : ".qmail-postmaster"
&root
File : ".qmail-root"
&guylhem
File : ".qmail-system"
&root
File : ".qmail-toor"
&root
File : ".qmail-uucp"
&root
File : ".qmail-uucp-default"
|preline -dr /usr/bin/uux - -r -gC -a"${SENDER:-MAILER-DAEMON}" lm!rmail "($DEFAULT@$HOST)"
您需要在 ~alias
中创建每个文件,将 .qmail-root
中的 &guylhem
替换为您自己的登录名以获取 root 邮件。
注意 UUCP 用户!
不要信任 QMAIL FAQ 中关于 UUCP 的内容,请改用我的 .qmail-uucp-default!否则您将无法通过 UUCP 连接发送任何邮件!
现在您需要决定您的用户将以哪种格式接收他们的邮件。
这是我的建议
要修复默认格式,请读取 /var/qmail/boot
中的每个文件,然后将您最喜欢的文件复制到 /var/qmail/rc
。
home
或 proc
是安全的选择,但出于安全原因,首选 home
。
在 /var/qmail/control 中,编辑
barberouge.linux.lmm.com
localnetwork
,这样发送到 joe@hisbox 的任何邮件都将完成,改为发送到 joe@hisbox.localnetwork。me
中设置),如果它以加号结尾。这 3 个示例向您展示了 qmail 配置的强大功能和易用性!
如果您想支持虚拟域名,只需在这些文件中添加其他名称。您收到的发送给这些名称的任何邮件都将在本地处理。
locals
和 rcpthosts
之间的区别在于后者不被视为本地别名,如果您从某些免费电子邮件地址(如 yahoo.com 或 lemel.fr)接收邮件,同时您也向这些非本地服务的其他用户发送邮件,这将非常有用,也就是说,您不想在本地处理发送给 someone@yahoo.com 的邮件!
在那里您可以指定默认的传出模式,例如
#:alias-uucp
如果您不想通过 uucp 发送传出邮件,而是通过 smtp(默认)或
:alias-ucp
如果您通过 uucp 发送传出邮件。
现在已配置,尝试
sh -cf '/var/qmail/rc &'
启动 qmail(它不会干扰您的本地 MTA),然后
echo to: mylogin | /var/qmail/bin/qmail-inject
您应该以您在 /var/qmail/boot/
中选择的格式收到此邮件。
如果此测试成功,只需终止您之前的 MTA
killall -STOP daemon_name ;如果有任何子进程正在运行,您应该 killall -CONT their_name,等待,再次 killall -STOP,并无限重复。
如果没有任何子进程,则 killall -TERM,然后 killall -CONT。
删除它(如何执行此操作取决于您安装的发行版,例如 RedHat、Caldera 和 Suse 上的 rpm -e --nodeps,或 Debian 上的 dpkg -r --force-depends),然后运行
# ln -s /var/qmail/bin/sendmail /usr/lib/sendmail
# ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail
现在在 /etc/inetd.conf 中设置 qmail-smtpd(全部在一行中)
smtp stream tcp nowait qmaild /var/qmail/bin/tcp-env tcp-env /var/qmail/bin/qmail-smtpd
如果您使用的是像 redhat 这样的旧的非 SYSV-init 发行版,只需添加到您的启动脚本中
sh -cf '/var/qmail/rc &'
通常这应该是 /etc/rc.local,但您的具体情况可能会有所不同。
对于实际符合 SYSV-init 标准的发行版(RedHat、Caldera、Suse、Debian),将此脚本添加到 /etc/init.d/ 或 /etc/rc.d/init.d/
DEBIAN 版本
#!/bin/sh
test -x /var/qmail/rc || exit 0
case "$1" in
start)
echo -n "Starting mta: "
sh -cf '/var/qmail/rc &'
echo "qmail."
;;
stop)
echo -n "Stopping mta: "
killall qmail-lspawn
echo "qmail."
;;
restart)
echo -n "Restarting mta: "
killall -HUP qmail-lspawn
killall -ALRM qmail-lspawn
echo "qmail."
;;
*)
echo "Usage: /etc/init.d/qmail {start|stop|restart}"
exit 1
esac
exit 0
REDHAT 版本
#!/bin/sh
#
# qmail This shell script takes care of starting and stopping qmail.
#
# description: qmail is a Mail Transport Agent, which is the program \
# that moves mail from one machine to another.
# processname: qmail
# config: /var/qmail/control/
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
export PATH=$PATH:/var/qmail/bin
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -f /usr/sbin/sendmail ] || exit 0
# See how we were called.
case "$1" in
start)
# Start daemons.
echo -n "Starting qmail: "
qmail-start '|preline procmail' splogger qmail &
touch /var/lock/subsys/qmail
echo
;;
stop)
# Stop daemons.
echo -n "Shutting down qmail: "
killproc qmail-lspawn
echo
rm -f /var/lock/subsys/qmail
;;
restart)
$0 stop
$0 start
;;
status)
status qmail
;;
*)
echo "Usage: qmail {start|stop|restart|status}"
exit 1
esac
exit 0
并为每个 /etc/rc.d/rcN.d/ 创建符号链接,例如
ln -sf /etc/init.d/qmail /etc/rc1.d/K19qmail
如果第一个字母是 K,您将在该运行级别(单用户模式为 1 或启动为 6)上终止 qmail,但如果第一个字母是 S,您将在该运行级别(其他每个运行级别)上启动 qmail。
对于 Debian 发行版,RedHat、Caldera 和 Suse 将使用 /etc/rc.d/ 而不是普通的 /etc/,例如 /etc/rc.d/rc1.d 或 /etc/rc.d/init.d。
无需重启(记住,您正在使用 Linux,而不是其他廉价操作系统!)即可使修改生效,只需运行
killall inetd
init 1
进入单用户模式,然后
init 2
返回您的默认运行级别(在 /etc/inittab 中使用 initdefault 标签指示)。
您也可以手动启动 qmail 脚本,但“init”方法将向您展示 qmail 脚本是否定位良好,即在网络脚本之后但在任何依赖电子邮件警告您的程序(如 inn)之前启动。
Smail 3.1 似乎是仅 uucp 站点和一些 smtp 站点的实际标准传输代理。它易于配置,可以从源代码编译而无需打补丁,并且相当安全。
从您的发行版安装 smail 二进制文件(我建议您选择此方法),或者获取 smail 源代码并构建 smail。如果您要从源代码构建 smail,则需要在您的 os/linux 文件中包含以下内容,以便“sed”为您提供可以正常工作的 shell 脚本。
CASE_NO_NEWLINES=true
安装完成后,配置文件肯定会放在 /etc/smail 中(如果您使用旧发行版,则您的具体情况可能会有所不同);让我们开始编辑它们!
# From
smart_path=polux
smart_transport=uux
# To
hostname=barberouge
domains=linux.lmm.com
visible_name=barberouge.linux.lmm.com
uucp_name=barberouge.linux.lmm.com
# max_message_size=512k
# auth_domains=foo.bar
# more_hostnames=barberouge.polux.freenix.fr
好的,首先,谁在为您提供服务?我由“polux”通过 uucp(即 uux 传输)提供服务;自然,您需要根据自己的情况更改此文件。例如,您可以通过“smtp”由“bargw.bar.foobar.com”提供服务,在这种情况下,您不需要传输文件,可以定义“-transport_file ”以指示您不需要传输文件。
您还可以使用“postmaster_address = yourname”,使用“visible_name”隐藏传出地址中的网络拓扑(如果您是网关),使用“more_hostnames”设置哪些别名地址也可以用于您收到的电子邮件。
有关更多详细信息,请参阅 smail 文档或 /usr/doc/smail/examples 中的示例,以查看是否有任何示例与您的情境相符。
# aliasinclude - expand ":include:filename" addresses produced by alias files
# This entry and the next one are pretty much boiler-plate. Reasons
# for making significant changes are few. The sole purpose of these
# is to match and expand addresses of the form:
# :include:pathname
# which may occur in alias files or mailing-list/forward files
# (produced by any director with a driver of forwardfile).
aliasinclude:
driver = aliasinclude, # use this special-case driver
nobody; # associate nobody user with addresses
# when mild permission violations
# are encountered
copysecure, # get permissions from alias director
copyowners, # get owners from alias director
# forwardinclude - expand ":include:filename" addrs produced by forward files
forwardinclude:
driver = forwardinclude, # use this special-case driver
nobody;
copysecure, # get perms from forwarding director
copyowners, # get owners from forwarding director
# aliases - search for alias expansions stored in a database
# This is the standard aliases file. It is used for generic things,
# like mapping root, postmaster, MAILER-DAEMON and uucp to site
# admins, creating some small system alias expansions, and such. In
# this site configuration, the aliases file is used mostly for
# machine-specific aliasing/forwarding information. Global forwarding
# information should be put in the "forward" database.
aliases:
driver=aliasfile, # general-purpose aliasing director
-nobody, # all addresses are associated
# with nobody by default, so setting
# this is not useful.
sender_okay, # don't remove sender from expansions
owner=owner-$user; # problems go to an owner address
file=/etc/aliases,
modemask=002, # should not be globally writable
optional, # ignore if file does not exist
proto=lsearch, # unsorted ASCII file
# forward - search for expansions stored in a forwarding database
# This is the subdomain-wide user forwarding database. Entries are
# maintained here for current or past users, to forward their mail to
# their preferred mail-reading machine. The forward database is
# shipped around the TCP/IP network as changes are made, to keep the
# network consistent.
#forward:
# driver = aliasfile, # general-purpose aliasing director
# -nobody, # all addresses are associated
# # with nobody by default, so setting
# # this is not useful.
# owner = real-$user; # problems go to an owner address
#
# file = /etc/forward,
# modemask = 002,
# proto = dbm, # use dbm(3X) library for access
# dotforward - expand .forward files in user home directories
# For users that have an entry in the "forward" database, a ".forward"
# file is only used if it is on the "home" machine, as identified in
# the forward database. If used, it is treated as a list of addresses
# to which mail should be delivered, rather than (or in addition to)
# the user identified in the local address.
dotforward:
driver = forwardfile, # general-purpose forwarding director
owner = postmaster, nobody, sender_okay;
file = ~/.forward, # .forward file in home directories
checkowner, # the user can own this file
owners = root, # or root can own the file
modemask = 002, # it should not be globally writable
caution = daemon:root, # don't run things as root or daemon
# be extra careful of remotely accessible home directories
unsecure = "~uucp:/tmp:/usr/tmp:/var/tmp"
# forwardto - expand a "Forward to " in user mailbox files
# This emulates the V6/V7/System-V forwarding mechanism which uses a
# line of forward addresses stored at the beginning of user mailbox files
# prefixed with the string "Forward to "
forwardto:
driver = forwardfile,
owner = postmaster, nobody, sender_okay;
file = /var/spool/mail/${lc:user}, # point at user mailbox files
forwardto, # enable "Forward to " function
checkowner, # the user can own this file
owners = root, # or root can own the file
modemask = 0002, # under System V, group mail can write
caution = daemon:root # don't run things as root or daemon
# user - match users on the local host with delivery to their mailboxes
user: driver = user; # driver to match usernames
transport = local # local transport goes to mailboxes
# real_user - match usernames when prefixed with the string "real-"
# This is useful for allowing an address which explicitly delivers to a
# user's mailbox file. For example, errors in a .forward file expansion
# could be delivered here, or forwarding loops between multiple machines
# can be resolved by using a real-username address. Also, users that
# wish to use mail as a means of transferring data to a machine that
# is not their "home" machine can mail to real-login-name@remote.host.
real_user:
driver = user;
transport = local,
prefix = "real-" # for example, match real-root
# lists - expand mailing lists stored in a list directory
# mailing lists can be created simply by creating a file in the
# /etc/smail/lists directory.
lists: driver = forwardfile,
caution, # flag all addresses with caution
nobody, # and then associate the nobody user
owner = owner-$user; # system V sites may wish to use
# o-$user, as owner-$user may be
# too long for a 14-char filename.
file = lists/${lc:user} # lists is under $smail_lib_dir
# owners - expand mailing lists stored in a list owner directory
# mailing lists owner lists can be created simply by creating a file
# in the /etc/smail/lists/owner directory. Mailing list owners
# are sent locally generated errors dealing with a mailing list of the
# same name. To create an owner list for a mailing list, create a
# file with the name of the list in /etc/smail/lists/owner. This
# will create a list address of owner-listname, as is used by the
# "lists" director above.
owners: driver = forwardfile,
caution, # flag all addresses with caution
nobody, # and then associate the nobody user
owner = postmaster; # system V sites may wish to use
# o-$user, as owner-$user may be
# too long for a 14-char filename.
prefix = "owner-",
file = lists/owner/${lc:user} # lists is under $smail_lib_dir
# request - expand mailing lists stored in a list request directory
# mailing lists request lists can be created simply by creating a file
# in the /etc/smail/lists/request directory. Request addresses
# are typically used as a standard address for queries about a mailing
# list. For example, requests for additions or deletions to a list
# will generally be sent to "list-request", which should be set up to
# forward to the appropriate person or persons.
request: driver = forwardfile,
caution, # flag all addresses with caution
nobody, # and then associate the nobody user
owner = postmaster; # system V sites may wish to use
# o-$user, as owner-$user may be
# too long for a 14-char filename.
suffix = "-request",
file = lists/request/${lc:user} # lists is under $smail_lib_dir
您应该不需要在此处进行任何更改,如果您打算使用 smail 运行某些邮件列表选项,或者如果您想禁用转发,则只需更改转发选项。
.f105.n324.z2.fidonet.org f105.n324.z2.fidonet.org!%s
.n324.z2.fidonet.org f105.n324.z2.fidonet.org!%s
.z2.fidonet.org f105.n324.z2.fidonet.org!%s
.fidonet.org f105.n324.z2.fidonet.org!%s
仅当您使用 ifmail 和 FIDO 时才创建此类文件。
# forces - force certain paths
# This database exists as a means of hardcoding the paths to various
# machines or domains. It is for use in creating temporary tweaks to
# the other routing databases. To change the database, edit the file
# maps/force.path and type "make" in the maps/ subdirectory.
forces:
driver = pathalias, # router to search paths file
method = /etc/smail/maps/table; # transports are in this file
file = forcepaths, # file containing force path info
proto = lsearch, # use the sorted path file
optional,
reopen # close when not being used
uucp_neighbors:
driver=uuname, # use a program which returns neighbors
transport=uux;
cmd="/usr/bin/uuname -a", # specifically, use the uuname program
# domain=uucp # strip ending ".uucp"
# smart_host - a partially specified smarthost director
# If the config file attribute smart_path is defined as a path from the
# local host to a remote host, then hostnames not matched otherwise will
# be sent off to the stated remote host. The config file attribute
# smart_transport can be used to specify a different transport.
# If the smart_path attribute is not defined, this router is ignored.
smart_host:
driver = smarthost, # special-case driver
transport = uux # by default deliver over UUCP
# path=phreak
# ifmail - to send mails to fidonet and vice versa
ifmail:
driver=pathalias,
transport=ifmail;
file=fidopaths,
proto=lsearch
仅当您将 ifmail 用于 FIDO 邮件时,才应包含 ifmail 章节。请注意,您还可以将传输模式从“uux”(即 UUCP)更改为例如“smtp”,甚至可以在“/etc/smail/maps/table”中“硬编码到各种机器或域的路径”。
如果您希望本地网络的传出邮件立即传递,这将非常有用,因为无需将其路由到您的 uucp 连接或互联网接入。
# local - deliver mail to local users
# Tell smail to append directly to user mailbox files in the /var/spool/mail
# directory.
#local: driver = appendfile, # append message to a file
# -return_path, # include a Return-Path: field
# local, # use local forms for delivery
# from, # supply a From_ envelope line
# unix_from_hack; # insert > before From in body
#
# file = /var/spool/mail/${lc:user}, # use this location for Linux
# # Note, mail spool must be 1777
# file = ~/mailfile, # use this location for better security
# group = mail, # group to own file for System V
# mode = 0660, # under System V, group mail can access
# suffix = "\n", # append an extra newline
# append_as_user,
# This allows each user to have a ~/.procmailrc file to control filtering
# of mail and saving mail from mail lists in separate mailboxes if they wish.
local: +inet,
-uucp,
driver = pipe, # append message to a file
return_path, # include a Return-Path: field
local, # use local forms for delivery
from, # supply a From_ envelope line
unix_from_hack; # insert > before From in body
cmd = "/usr/bin/procmail", # use procmail for local delivery
parent_env, # environment info from parent addr
pipe_as_user, # use user-id associated with address
umask = 0022, # umask for child process
# -ignore_status, # exit status should be believed
# -ignore_write_errors, # retry on broken pipes
# pipe - deliver mail to shell commands
# This is used implicitly when smail encounters addresses which begin with
# a vertical bar character, such as "|/usr/lib/news/recnews talk.bizarre".
# The vertical bar is removed from the address before being given to the
# transport.
#pipe: driver = pipe, # pipe message to another program
# return_path, local, from, unix_from_hack;
#
# cmd = "/bin/sh -c $user", # send address to the Bourne Shell
# parent_env, # environment info from parent addr
# pipe_as_user, # use user-id associated with address
# umask = 0022, # umask for child process
# -log_output, # do not log stdout/stderr
# ignore_status, # exit status may be bogus, ignore it
# ignore_write_errors, # ignore broken pipes
# file - deliver mail to files
# This is used implicitly when smail encounters addresses which begin with
# a slash or squiggle character, such as "/usr/info/list_messages" or
# perhaps "~/Mail/inbox".
#file: driver = appendfile,
# return_path, local, from, unix_from_hack;
#
# file = $user, # file is taken from address
# append_as_user, # use user-id associated with address
# expand_user, # expand ~ and $ within address
# check_path,
# suffix = "\n",
# mode = 0644
# uux - deliver to the rmail program on a remote UUCP site
#
# As many as five recipient addresses will be delivered to the remote
# host in one UUCP transaction.
uux: driver = pipe,
-uucp,
inet,
# uucp, # use UUCP-style addressing forms
from, # supply a From_ envelope line
max_addrs = 5, # at most 5 addresses per invocation
max_chars = 200; # at most 200 chars of addresses
# the -r flag prevents immediate delivery, parentheses around the
# $user variable prevent special interpretation by uux.
cmd = "/usr/bin/uux - -r -g$grade $host!rmail $((${strip:user})$)",
# cmd="/usr/bin/uux - $host!rmail $(($user)$)",
ignore_write_errors, # ignore broken pipes
umask = 0022,
# pipe_as_sender,
# uux_one_addr - deliver mail over UUCP to a remote host that can take
# one address at a time.
# This is often necessary when delivering to a site running an unmodified
# version of 4.1BSD.
uux_one_addr:
driver = pipe,
uucp, # use UUCP-style addressing forms
from; # supply a From_ envelope line
# the -r flag prevents immediate delivery
cmd = "/usr/bin/uux - -r -g$grade $host!rmail (${strip:user})",
umask = 0022,
pipe_as_sender
queueonly:
driver = pipe; # send the message to a pipe
cmd = "/usr/lib/sendmail -Q -f $sender -bm $user",
# use getmail for local delivery
user=root, # execute getmail as "root"
group=mail, # execute getmail as "mail"
parent_env, # environment info from parent addr
-pipe_as_user, # use user-id associated with address
umask = 0007, # umask for child process
# to deliver the message. The smtp transport is included only if BSD
# networking exists.
# The uucp attribute can be specified for transfers within the UUCP
# zone. The inet attribute must be specified for transfers within the
# Internet.
# NOTE: This is hardly optimal, a backend should exist which can handle
# multiple messages per connection.
# ALSO: It may be necessary to restrict max_addrs to 100, as this is the
# lower limit SMTP requires an implementation to handle for one
# message.
smtp: driver=tcpsmtp,
inet, # if UUCP_ZONE is not defined
# uucp, # if UUCP_ZONE is defined
-max_addrs, -max_chars; # no limit on number of addresses
short_timeout=5m, # timeout for short operations
long_timeout=2h, # timeout for longer SMTP operations
service=smtp, # connect to this service port
# For internet use: uncomment the below 4 lines
use_bind, # resolve MX and multiple A records
defnames, # use standard domain searching
defer_no_connect, # try again if the nameserver is down
local_mx_okay, # fail an MX to the local host
ifmail:
from,received,max_addrs=5,max_chars=200,
driver=pipe;
pipe_as_sender,
cmd="/usr/local/bin/ifmail -x9 -r$host $((${strip:user})$)"
仅当您将 ifmail 用于 FIDO 邮件时,才应包含 ifmail 章节。除此之外,您应该不需要编辑此文件中的任何内容,该文件定义了您可以在其他配置文件中用作参数的传输代理(如 uux、smtp ...)。
请注意,我注释掉了一些部分,例如“pipes”或“file”,以增强安全性。
它包含 map
和 table
文件
首先,map
文件
#N foo.bar foo2.bar2
#S AT 486/RedHat Linux 1.2.13
#O organization
#C contact
#E administration (email)
#T phone
#P address
#R
#U hosts connected via uucp
#W created/edited by
#
hname polux
hname linux.eu.org
hname = polux
hname = polux.linux.eu.org
再次,编辑此文件以匹配您的情况(我由 polux.linux.eu.org 提供服务)。
现在是 table
文件
* uux
您可以为不同的路径定义不同的传输,例如,本地网络中的机器使用“smtp”,世界其他地方使用“uux”(即 uucp),反之亦然(我使用 uucp 发送任何传出邮件,因此我使用“*”!)。
前面的文件是我目前为我的站点使用的文件,您应该不会遇到任何问题,可以将它们用作您自己的文件的示例/基础。
以下文件仅作为配置 smail 的不同方式的良好示例提供。
#ident "@(#) transports,v 1.2 1990/10/24 05:20:46 tron Exp"
# See smail(5) for a complete description of the contents of this file.
# local - deliver mail to local users
#
# Tell smail to append directly to user mailbox files in the /usr/mail
# directory.
local: driver = appendfile, # append message to a file
return_path, # include a Return-Path: field
local, # use local forms for delivery
from, # supply a From_ envelope line
unix_from_hack; # insert > before From in body
file = /usr/mail/${lc:user}, # use this location for System V
group = mail, # group to own file for System V
mode = 0660, # under System V, group mail can access
suffix = "\n", # append an extra newline
append_as_user,
# pipe - deliver mail to shell commands
#
# This is used implicitly when smail encounters addresses which begin with
# a vertical bar character, such as "|/usr/lib/news/recnews talk.bizarre".
# The vertical bar is removed from the address before being given to the
# transport.
pipe: driver = pipe, # pipe message to another program
return_path, local, from, unix_from_hack;
cmd = "/bin/sh -c $user", # send address to the Bourne Shell
parent_env, # environment info from parent addr
pipe_as_user, # use user-id associated with address
umask = 0022, # umask for child process
-log_output, # do not log stdout/stderr
ignore_status, # exit status may be bogus, ignore it
ignore_write_errors, # ignore broken pipes
# file - deliver mail to files
#
# This is used implicitly when smail encounters addresses which begin with a
# slash or squiggle character, such as "/usr/info/list_messages" or perhaps
# "~/Mail/inbox".
file: driver = appendfile,
return_path, local, from, unix_from_hack;
file = $user, # file is taken from address
append_as_user, # use user-id associated with address
expand_user, # expand ~ and $ within address
suffix = "\n",
mode = 0644
# uux - deliver to the rmail program on a remote UUCP site
#
# As many as five recipient addresses will be delivered to the remote host in
# one UUCP transaction.
uux: driver = pipe,
uucp, # use UUCP-style addressing forms
from, # supply a From_ envelope line
max_addrs = 5, # at most 5 addresses per invocation
max_chars = 200; # at most 200 chars of addresses
# the -r flag prevents immediate delivery, parentheses around the
# $user variable prevent special interpretation by uux.
cmd = "/usr/bin/uux - -r -g$grade $host!rmail $((${strip:user})$)",
umask = 0022,
pipe_as_sender
# uux_one_addr - deliver mail over UUCP to a remote host that can take one
# address at a time.
#
# This is often necessary when delivering to a site running an unmodified
# version of 4.1BSD.
uux_one_addr:
driver = pipe,
uucp, # use UUCP-style addressing forms
from; # supply a From_ envelope line
# the -r flag prevents immediate delivery
cmd = "/usr/bin/uux - -r -g$grade $host!rmail (${strip:user})",
umask = 0022, pipe_as_sender
# demand - deliver to a remote rmail program, polling on demand
demand: driver = pipe,
uucp, from, max_addrs = 5, max_chars = 200;
# with no -r flag, try to contact remote site immediately
cmd = "/usr/bin/uux - -g$grade $host!rmail $(($user)$)",
umask = 0022, pipe_as_sender
# uusmtp - deliver to the rsmtp program on a remote UUCP site
#
# Deliver using a simple Batched SMTP protocol to the remote machine.
# This allows much more arbitrary addresses to be used. It also
# removes the limit on recipient addresses per invocation of uux.
uusmtp: driver = pipe,
bsmtp, # send batched SMTP commands
-max_addrs, # there is no limit on the number or
-max_chars; # total size of recipient addresses.
# supply -r to prevent immediate delivery, the recipient addresses
# are stored in the data sent to the standard input of rsmtp.
cmd = "/usr/bin/uux - -r -g$grade $host!rsmtp",
umask = 0022, pipe_as_sender
# demand_uusmtp - deliver to a remote rsmtp program, polling on demand
demand_uusmtp:
driver = pipe,
bsmtp, -max_addrs, -max_chars;
# with no -r flag, try to contact remote site immediately
cmd = "/usr/bin/uux - -g$grade $host!rsmtp",
umask = 0022, pipe_as_sender
# smtp - deliver using SMTP over TCP/IP
#
# Connect to a remote host using TCP/IP and initiate an SMTP conversation to
# deliver the message. The smtp transport is included only if BSD networking
# exists.
# NOTE: It may be necessary to restrict max_addrs to 100, as this is the
# lower limit SMTP requires an implementation to handle for one
# message.
smtp: driver = smtp,
-max_addrs,
-max_chars
#ident "@(#) table,v 1.2 1990/10/24 05:20:31 tron Exp"
# This file names the transports that are to be used in delivering
# to specific hosts from bargw.
#host transport
#-------- ---------
curdsgw demand_uusmtp # deliver using batched SMTP
oldbsd uux_one_addr # 4.1BSD sites cannot take more than one addr
sun demand # call sun when their is mail to send
* uux # for all others, poll at intervals
要将 smail 作为 smtp 守护进程运行,请将以下内容之一添加到 /etc/inetd.conf
smtp stream tcp nowait root /usr/bin/smtpd smtpd or: smtp stream tcp nowait root /usr/sbin/tcpd /usr/sbin/in.smtpd
使用 elm 时,传出邮件会自动发送。
通常,ISP 使用 smtp,因此您应该没有任何发送邮件的问题。如果当您发送邮件时您的互联网链接断开,则邮件会停留在“/var/spool/smail/input
”中。当链接下次恢复时,将运行“runq
”,这会导致邮件被发送。但是,接收邮件是问题,因为您的提供商需要照顾许多客户端,而不仅仅是您!
通常,您可以通过 POP 协议检索您的邮件,请参阅下面的 POP 章节。
对于大型站点,sendmail 值得选择,因为它“非常易于使用”(当您了解 qmail 时,这是一种非常相对的感觉),但您必须决定选择 sendmail+IDA 还是 sendmail 8.x
请记住,Linux 新手或关注安全性/易于配置的人员应该尝试使用 smail 或 qmail,它们更易于使用且更安全。
如果您的发行版未向您提供现成的 sendmail 软件包(RedHat、Caldera 和 Suse 的 .rpm,Debian 的 .deb),只需下载源代码并运行
编辑掉分发的 hostname、aliases、smarthost,并放入您站点的正确 hostname、aliases、smarthost。默认文件适用于仅 uucp 站点(不再在 8.x 中),该站点具有域化的标头并与智能主机通信。然后“make yourhostname.cf”并将生成的文件移动到 /etc/sendmail.cf
您只需触摸这些文件即可使 Makefile 工作。只需编辑 .m4 文件,制作 sendmail.cf 并开始测试即可。
您还应该将您的版本更新到至少 5.67b,因为 5.67a 及更早版本中存在严重的安全性漏洞。另一个好处是,如果您设置了 mail.debug 并运行了 syslogd,您的传入和传出邮件消息将被记录。有关详细信息,请参阅“/etc/syslog.conf”文件。
sendmail+IDA 的源代码可以在 vixen.cso.uiuc.edu 上找到;如果您运行内核 1.00 之类的内核,它们无需打补丁即可在 Linux 下运行。
如果您运行的内核 > 1.1.50,您将获得反转现在在 vanilla 源代码中的大多数 Linux 特定补丁的乐趣。(我*确实*告诉过您此 sendmail 仅适用于旧内核:-))
这需要在哪里完成非常明显:只需键入“make”,当它崩溃时,转到源代码中的该行并注释掉那里的 Linux 特定代码。
如果您要运行 sendmail+IDA,我强烈建议您转到 sendmail5.67b+IDA1.5 版本,因为所有必需的 Linux 特定补丁现在都在 vanilla 源代码中,并且已修复了许多安全漏洞,这些漏洞在您在 1993 年 12 月 1 日之前抓取或构建的旧版本中(!!!)存在。
现在 linux 内核是 2.0,您应该使用 sendmail 8.x 而不是 sendmail+IDA,但我已经告诉过您最好选择 sendmail 8.x :-)
Sendmail+IDA 要求您设置 sendmail.m4
文件,而不是直接编辑 sendmail.cf
文件。这样做的好处是,可以轻松设置在 smail 或传统 sendmail 中极其困难(如果不是大多数人完全不可能正确设置)的邮件配置。
与上述 smail 示例对应的 sendmail.m4 文件如下所示
dnl #------------------ SAMPLE SENDMAIL.M4 FILE ------------------ dnl # dnl # (the string 'dnl' is the m4 equivalent of commenting out a line) dnl # (well, not exactly, but use it for this purpose if you must :-) dnl # you generally don't want to override LIBDIR from the compiled in paths dnl #define(LIBDIR,/usr/local/lib/mail)dnl # where all support files go define(LOCAL_MAILER_DEF, mailers.linux)dnl # mailer for local delivery define(POSTMASTERBOUNCE)dnl # postmaster gets bounces define(PSEUDODOMAINS, BITNET UUCP)dnl # don't try DNS on these dnl # dnl #------------------------------------------------------------- dnl # dnl # names we're known by define(PSEUDONYMS, myhostname.subdomain.domain myhostname.UUCP) dnl # dnl # our primary name define(HOSTNAME, myhostname.subdomain.domain) dnl # dnl # our uucp name define(UUCPNAME, myhostname)dnl dnl # dnl #------------------------------------------------------------- dnl # define(UUCPNODES, |uuname|sort|uniq)dnl # our uucp neighbors define(BANGIMPLIESUUCP)dnl # make certain that uucp define(BANGONLYUUCP)dnl # mail is treated correctly define(RELAY_HOST, my_uucp_neighbor)dnl # our smart relay host define(RELAY_MAILER, UUCP-A)dnl # we reach moria via uucp dnl # dnl #-------------------------------------------------------------------- dnl # dnl # the various dbm lookup tables dnl # define(ALIASES, LIBDIR/aliases)dnl # system aliases define(DOMAINTABLE, LIBDIR/domaintable)dnl # domainize hosts define(PATHTABLE, LIBDIR/pathtable)dnl # paths database define(GENERICFROM, LIBDIR/generics)dnl # generic from addresses define(MAILERTABLE, LIBDIR/mailertable)dnl # mailers per host or domain define(UUCPXTABLE, LIBDIR/uucpxtable)dnl # paths to hosts we feed define(UUCPRELAYS, LIBDIR/uucprelays)dnl # short-circuit paths dnl # dnl #-------------------------------------------------------------------- dnl # dnl # include the 'real' code that makes it all work dnl # (provided with the source code) dnl # include(Sendmail.mc)dnl # REQUIRED ENTRY!!! dnl # dnl #------------ END OF SAMPLE SENDMAIL.M4 FILE -------
与大多数 Unix 发行版不同,Linux 默认情况下未附带本地邮件传递代理。
Slackware 附带了!好吧,至少易于使用但冗长的安装脚本提供了它。它使用 procmail。
现在,deliver 或 procmail 通常已安装,并带有默认的 sendmail 设置来处理本地邮件,因此不会为此已经非常复杂的设置增加任何复杂性。我建议使用常用的 deliver
或 procmail
程序,它们在某些 Linux 发行版中可以是可选软件包。
为了做到这一点,您需要在 sendmail.m4
文件中定义一个 LOCAL_MAILER_DEF
,该文件指向一个看起来像这样的文件
# -- /usr/local/lib/mail/mailers.linux -- # (local mailers for use on Linux ) Mlocal, P=/usr/bin/deliver, F=SlsmFDMP, S=10, R=25/10, A=deliver $u Mprog, P=/bin/sh, F=lsDFMeuP, S=10, R=10, A=sh -c $u
在 Sendmail.mc
文件中也为 deliver
内置了默认值,该文件包含在 sendmail.cf
文件中。要指定它,您将不使用 mailers.linux
文件,而是改为在您的 sendmail.m4 文件中定义以下内容
dnl --- (in sendmail.m4) --- define(LOCAL_MAILER_DEF, DELIVER)dnl # mailer for local delivery
不幸的是,Sendmail.mc 假设 deliver 安装在 /bin 中,而 Slackware 1.1.1(将其安装在 /usr/bin 中)并非如此。在这种情况下,您需要使用链接来伪造它,或者从源代码重建 deliver,以便它驻留在 /bin 中。请注意,procmail 通常比 deliver 更好,例如用于邮件过滤。
为站点或域设置特殊行为是通过许多可选的 dbm
表而不是直接编辑 sendmail.cf
文件来完成的。
有关更多详细信息,请参阅 1994 年 7 月的 Linux Journal
期刊(如果您仍然可以找到它:-))、源代码中的文档或最新版本的 Linux 文档项目 网络管理指南
中的 sendmail 章节,该指南即将发布。
当不使用任何可选的 dbm 表时,sendmail 通过在用于生成 sendmail.cf 的 sendmail.m4 文件中定义的 RELAY_HOST
和 RELAY_MAILER)
传递邮件。通过 domaintable 或 uucpxtable 中的条目可以轻松覆盖此行为。
连接到互联网并使用域名服务的通用站点,或者仅使用 UUCP 并通过智能 RELAY_HOST
通过 UUCP 转发所有邮件的站点,可能根本不需要任何特定的表条目。
几乎所有系统都应设置 DEFAULT_HOST
和 PSEUDONYMS
宏,它们定义了规范站点名称及其已知的别名。
如果您的所有设置只是中继主机和中继邮件程序,则您无需设置这些默认值,因为它会自动工作。UUCP 主机可能还需要将其 UUCPNAME
设置为其官方 UUCP 名称。
他们可能还需要设置 RELAY_MAILER
和 RELAY_HOST
,它们启用通过邮件中继的智能主机路由。
要使用的邮件传输在 RELAY_MAILER
中定义,对于 UUCP 站点,通常应为 UUCP-A。如果您的站点仅使用 SMTP 并使用“域名服务”,则应更改 RELAY_MAILER
。
如果您是 SLIP 站点,您可能希望采取简单的方法,只需将所有传出邮件转发给您的服务提供商即可,以便他们进行正确的处理。为此,您需要将 ISOLATED_DOMAINS 和 VALIDATION_DOMAINS 定义为您的域,您还需要将 RELAY_HOST 定义为您的服务提供商,并将 RELAY_MAILER 定义为 TCP。当然,在将任何系统设置为您的通用中继之前,您需要征得许可。
来自 Berkeley 的 Sendmail 8.7.x 是 sendmail 5 之后的最新主要修订版。它对在 Linux 下构建具有出色的内置支持:只需“make linux”即可完成所有设置。
您最好从常用的 Linux 存档站点抓取各种二进制发行版之一,而不是自己与 Berkeley dbm 作斗争。
Jason Haar 提供了一个不错的 sendmail 8.6.12 发行版 - j.haar at lazerjem.demon.co.uk
,位于 sunsite.unc.edu 的 /pub/Linux/system/Mail/delivery/sendmail-8.6.12-bin.tgz 中,其中包含源代码文档以及关于如何为常见配置运行 sendmail v8 的非常好的快速描述。
sendmail v8 的底线是您希望配置完成工作所需的最少内容;以下是一个示例,至少应该让您接近目标。
与 sendmail+IDA 非常相似,sendmail v8 使用 m4 将配置文件处理成 sendmail 使用的完整 sendmail.cf。以下是我当前站点的 mc 文件(通过 ppp 连接到互联网发送传出邮件,通过 uucp 接收传入邮件)。
dnl divert(-1) #--------------------------------------------------------------------- # # this is the .mc file for a linux host that's set up as follows: # # - connected to Internet for outbound mail (ppp here) # - connected via UUCP for incoming mail # - domainized headers # - no local mailer (use 'deliver' instead) # - no DNS running so don't canonicalize outgoing via DNS # - all non-local outbound mail goes to the RELAY_HOST over smtp # (we run ppp and let our service provider do the work) # # vds 3/31/95 # #--------------------------------------------------------------------- include(`../m4/cf.m4') VERSIONID(`linux nodns relays to slip service provider smarthost')dnl Cwmyhostname.myprimary.domain myhostname.UUCP localhost OSTYPE(linux) FEATURE(nodns)dnl FEATURE(always_add_domain)dnl FEATURE(redirect) FEATURE(nocanonify) dnl MAILER(local)dnl MAILER(smtp)dnl MAILER(uucp)dnl define(`RELAY_HOST', smtp:my.relay.host.domain) define(`SMART_HOST', smtp:my.relay.host.domain) define(`UUCP_RELAY', smtp:my.relay.host.domain) define(`LOCAL_MAILER_PATH', `/bin/deliver') define(`LOCAL_MAILER_ARGS', `deliver $u')
我想对于我们中的“IDA 顽固分子”来说,存在一些差异。到目前为止,我发现了以下内容
您键入“sendmail -q”来运行队列,而不是“runq”!
与大多数操作系统不同,Linux 没有“内置”邮件:您需要一个程序来传递本地邮件,例如“lmail”、“procmail”或“deliver”。
但是,现在每个最新的发行版都包含本地邮件程序!
有关如何将两者用于本地传递的文档在上面提到的 sendmail5.67b+IDA1.5 二进制发行版(在 sunsite 上)中。