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@$domainnSubject: Your mailbox fullnnThis message is automatical