EXIM是Debian默认的MTA,轻盈小巧,而且功能完整
是小型网络和单机的最佳选择
前提条件:具有Internet连接,有正确的DNS的MX记录指向你的smtp服务器
Debian Linux 缺省安装的邮件传输服务软件为 exim 3.35 。下面为 exim 的设置过程:
一、基本配置
==============================================================================
You must choose one of the options below:
(1) Internet site; mail is sent and received directly using SMTP. If your
needs don't fit neatly into any category, you probably want to start
with this one and then edit the config file by hand.
(2) Internet site using smarthost: You receive Internet mail on this
machine, either directly by SMTP or by running a utility such as
fetchmail. Outgoing mail is sent using a smarthost. optionally with
addresses rewritten. This is probably what you want for a dialup
system.
(3) Satellite system: All mail is sent to another machine, called a "smart
host" for delivery. root and postmaster mail is delivered according
to /etc/aliases. No mail is received locally.
(4) Local delivery only: You are not on a network. Mail for local users
is delivered.
(5) No configuration: No configuration will be done now; your mail system
will be broken and should not be used. You must then do the
configuration yourself later or run this script, /usr/sbin/eximconfig,
as root. Look in /usr/share/doc/exim/example.conf.gz
Select a number from 1 to 5, from the list above.
Enter value (default=`1', `x' to restart):1
这里选择1,使这台机器作为一台互联网上的标准SMTP邮件传输服务器。
==============================================================================
What is the `visible' mail name of your system? This will appear on
From: lines of outgoing messages.
Enter value (default=`smtp.foo.com', `x' to restart):
这里我们确认邮件域的名称,缺省系统使用主机的名称;可以根据实际情况设置。
==============================================================================
Does this system have any other names which may appear on incoming
mail messages, apart from the visible name above (smtp.foo.com) and
localhost?
By default all domains will be treated the same; if you want different
domain names to be treated differently, you will need to edit the config
file afterwards: see the documentation for the "domains" director
option.
If there are any more, enter them here, separated with spaces or commas.
If there are none, say `none'.
Enter value (default=`none', `x' to restart):foo.com
这里我们来设置除了缺省的邮件域,还可以接受什么邮件域,作为本地邮件域。注意,这里需要与本地DNS的
MX记录相配合。
==============================================================================
All mail from here or specified other local machines to anywhere on
the internet will be accepted, as will mail from anywhere on the
internet to here.
Are there any domains you want to relay mail for---that is, you are
prepared to accept mail for them from anywhere on the internet, but
they are not local domains.
If there are any, enter them here, separated with spaces or commas. You
can use wildcards. If there are none, say `none'. If you want to relay
mail for all domains that specify you as an MX, then say `mx'
Enter value (default=`none', `x' to restart):
我们可以指定转发域,也可通过MX 记录指定转发域,这样将不会要求认证。
==============================================================================
Obviously, any machines that use us as a smarthost have to be excluded
from the relaying controls, as using us to relay mail for them is the
whole point.
Are there any networks of local machines you want to relay mail for?
If there are any, enter them here, separated with spaces or commas. You
should use the standard address/length format (e.g. 194.222.242.0/24)
If there are none, say `none'.
You need to double the colons in IPv6 addreses (e.g. 5f03::1200::836f::::/48)
Enter value (default=`none', `x' to restart):
我们在后面要设置通过认证来转发邮件,所以我们这里使用缺省值none。
==============================================================================
Mail for the `postmaster' and `root' accounts is usually redirected
to one or more user accounts, of the actual system administrators.
By default, I'll set things up so that mail for `postmaster' and for
various system accounts is redirected to `root', and mail for `root'
is redirected to a real user. This can be changed by editing /etc/aliases.
Note that postmaster-mail should usually be read on the system it is
directed to, rather than being forwarded elsewhere, so (at least one of)
the users you choose should not redirect their mail off this machine.
Which user account(s) should system administrator mail go to ?
Enter one or more usernames separated by spaces or commas . Enter
`none' if you want to leave this mail in `root's mailbox - NB this
is strongly discouraged. Also, note that usernames should be lowercase!
Enter value (`x' to restart):eagle
这里我们将系统的缺省用户的信件转给一个实际的管理员邮件账户。
The following configuration has been entered:
==============================================================================
Mail generated on this system will have `smtp.foo.com' used
as the domain part (after the @) in the From: field and similar places.
The following domain(s) will be recognised as referring to this system:
localhost, smtp.foo.com, foo.com
Mail for postmaster, root, etc. will be sent to eagle.
Local mail is delivered.
Outbound remote mail is looked up in the Internet DNS, and delivered
using that data if any is found; otherwise such messages are bounced.
Note that you can set email addresses used for outgoing mail by editing
/etc/email-addresses.
Is this OK ? Hit Return or type `y' to confirm it and install,
or `n' to make changes (in which case we'll go round again, giving you
your previous answers as defaults. (Y/n)
这里系统提示配置结果,接受上述设置。
Keeping previous /etc/exim/exim.conf as /etc/exim/exim.conf.O
Keeping previous /etc/aliases as /etc/aliases.O
Keeping previous /etc/mailname as /etc/mailname.O
Configuration installed.
系统将保存相关配置文件。
二、微调
这里我们对一些常用功能进行配置和补充,使其成为一个可以实际工作的邮件服务器。
1.增加转发域
relay_domains = *.foo.com
# 接受从外部进入的、目的域为foo.com的邮件转发。否则邮件无法进入。
2.检查邮件头,判断用户是否存在
sender_verify = true
# If this option is true, envelope sender addresses on incoming SMTP messages are checked to ensure that they are valid.
3.限制邮箱的大小
在 TRANSPORTS CONFIGURATION 的 local_delivery 加入:
maildir_tag = ,S=$message_size
quota = ${lookup{$local_part}lsearch*{/etc/exim/quota}{$value}{0M}}
quota_size_regex = S=(\d+)$
quota_warn_threshold = 85%
quota_warn_message = "To: $local_part@$domain\nSubject: Your mailbox full\n\nThis message is automatical