26.2 使用電子郵件

在 email 交換的過程中有 5 個主要部分,分別是:MUAMTADNS遠端或本機的信箱,當然還有 郵件主機本身

26.2.1 MUA 程式

包括一些文字介面的程式,像是 muttpineelm、 and mail,以及 GUI 介面的程式, 像是 balsaxfmail 等等。 此外,還有更 “複雜的” 像是 WWW 瀏覽器。 這些程式會郵件處理交給 “郵件主機”,或者透過呼叫 MTA(若有的話)或者是透過 TCP 來傳遞郵件。

26.2.2 MTA

FreeBSD 預設是採 sendmail 作為 MTA, 但也支援許多其他的 MTA,茲舉例如下:

Mail server daemon 通常有兩種功能 —— 收信、發信。 不過並 不負責 使用類似 POPIMAP 之類的協定來讀取信件, 也不負責連到本機的 mbox 或 Maildir 信箱。 這些必須要用其他的 daemon 才可以。

Warning: 舊版的 sendmail 有一些嚴重的安全漏洞, 會導致攻擊者可以從遠端或本機來控制主機。 使用前最好先確認目前所用的是最新的,以避免這些不必要的問題。 此外, 也可透過 FreeBSD Ports Collection 來安裝其他的 MTA

26.2.3 Email 及 DNS

Domain Name System (DNS) 及其 daemon 程式(named) 在信件傳遞過中當中,扮演相當重要的角色。 為了要能順利發信出去給其他地方 ,mail server daemon 會透過 DNS 來查詢要收信的地方為何。 同樣地, 外面若要寄信到你的機器,也會作 DNS 查詢。

DNS 會負責 hostname 與 IP 位址之間的對應, 同時也會記錄郵件傳遞時所需的資訊,這些資訊即是所謂的 MX (Mail eXchanger) 紀錄。 IP 位址被存放在 A 記錄中,而 MX 記錄存放的是該 domain 的郵件是由哪台(或哪些)機器要負責收。 若要收信的機器或該 domain 沒有設定 MX 記錄的話, 則郵件會直接傳給該 hostname 所對應的 A 紀錄所記載之 IP 上。

此外,可以透過 host(1) 指令來查詢任何 domain 所對應的 MX 紀錄為何,就像下面這樣:

% host -t mx FreeBSD.org
FreeBSD.org mail is handled (pri=10) by mx1.FreeBSD.org

26.2.4 收信

Receiving mail for your domain is done by the mail host. It will collect all mail sent to your domain and store it either in mbox (the default method for storing mail) or Maildir format, depending on your configuration. Once mail has been stored, it may either be read locally using applications such as mail(1) or mutt, or remotely accessed and collected using protocols such as POP or IMAP. This means that should you only wish to read mail locally, you are not required to install a POP or IMAP server.

26.2.4.1 Accessing remote mailboxes using POP and IMAP

In order to access mailboxes remotely, you are required to have access to a POP or IMAP server. These protocols allow users to connect to their mailboxes from remote locations with ease. Though both POP and IMAP allow users to remotely access mailboxes, IMAP offers many advantages, some of which are:

  • IMAP can store messages on a remote server as well as fetch them.

  • IMAP supports concurrent updates.

  • IMAP can be extremely useful over low-speed links as it allows users to fetch the structure of messages without downloading them; it can also perform tasks such as searching on the server in order to minimize data transfer between clients and servers.

In order to install a POP or IMAP server, the following steps should be performed:

  1. Choose an IMAP or POP server that best suits your needs. The following POP and IMAP servers are well known and serve as some good examples:

    • qpopper;

    • teapop;

    • imap-uw;

    • courier-imap;

  2. Install the POP or IMAP daemon of your choosing from the ports collection.

  3. Where required, modify /etc/inetd.conf to load the POP or IMAP server.

Warning: It should be noted that both POP and IMAP transmit information, including username and password credentials in clear-text. This means that if you wish to secure the transmission of information across these protocols, you should consider tunneling sessions over ssh(1). Tunneling sessions is described in Section 14.11.8.

26.2.4.2 Accessing local mailboxes

Mailboxes may be accessed locally by directly utilizing MUAs on the server on which the mailbox resides. This can be done using applications such as mutt or mail(1).

26.2.5 The Mail Host

The mail host is the name given to a server that is responsible for delivering and receiving mail for your host, and possibly your network.

本文及其他文件,可由此下載:ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/

若有 FreeBSD 方面疑問,請先閱讀 FreeBSD 相關文件,如不能解決的話,再洽詢 <questions@FreeBSD.org>。
關於本文件的問題,請洽詢 <doc@FreeBSD.org>。