There are five major parts involved in an email exchange: the Mail User Agent MUA>, the Mail Transfer AgentMTA, DNS, a remote or local mailbox, and the mail host.
This includes command line programs such as
mutt,
alpine,
elm, and
mail
, GUI programs such
as balsa or
xfmail, and web mail programs
which can be accessed from a web browser. User programs pass
the email transactions to the local “mail host”, either
by a MTA, or by
delivering it over TCP.
FreeBSD ships with Sendmail as the default MTA, but it also supports numerous other mail server daemons, including:
Exim;
Postfix;
qmail.
The MTA usually has two functions. It
is responsible for receiving incoming mail as well as
delivering outgoing mail. It is not
responsible for the collection of mail using protocols such as
POP or IMAP, nor does it
allow connecting to local mbox
or Maildir
mailboxes. An additional daemon may be required for
these functions.
Older versions of Sendmail contain serious security issues which may result in an attacker gaining local or remote access to the system. Run a current version to FreeBSD to avoid these problems. Optionally, install an alternative MTA from the FreeBSD Ports Collection.
The Domain Name System (DNS) and its
daemon named
play a large role in the
delivery of email. In order to deliver mail from one site to
another, the MTA will look up the remote
site in DNS to determine which host will
receive mail for the destination. This process also occurs
when mail is sent from a remote host to the
MTA.
DNS is responsible for mapping
hostnames to IP addresses, as well as for storing information
specific to mail delivery, known as Mail eXchanger
MX records. The MX
record specifies which host, or hosts, will receive mail for a
particular domain. If there is no MX
record for the hostname or domain, the mail will be delivered
directly to the host, provided there is an
A
record pointing the hostname to the IP
address.
To view the MX records for a domain, specify the type of record using host(1), as seen in the example below:
%
host -t mx FreeBSD.org
FreeBSD.org mail is handled by 10 mx1.FreeBSD.orgReceiving mail for a domain is done by the mail host.
It will collect all mail sent to the domain and store it
either in the default mbox
or the
alternative Maildir format, depending on the configuration.
Once mail has been stored, it may either be read locally using
a MUA, or remotely accessed and collected
using protocols such as POP or
IMAP. In order to read mail locally,
a POP or IMAP server
does not need to be installed.
To access mailboxes remotely, access to a POP or IMAP server is required. These protocols allow users to connect to their mailboxes from remote locations. Though both POP and IMAP allow users to remotely access mailboxes, IMAP offers many advantages, including:
IMAP can store messages on a remote server as well as fetch them.
IMAP supports concurrent updates.
IMAP can be 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:
Use the Ports Collection to install an IMAP or POP server. The following POP and IMAP servers are well known:
mail/qpopper
mail/teapop
mail/imap-uw
mail/courier-imap
mail/dovecot2
Where required, use the startup script that came
with the application to load the POP
or IMAP server. Those programs will
also provide a variable which can be added to
/etc/rc.conf
to automate the
startup of the application's daemon whenever the system
boots.
It should be noted that both POP and IMAP transmit information, including username and password credentials, in clear-text. To secure the transmission of information across these protocols, consider tunneling sessions over ssh(1) (Section 15.10.8, “SSH Tunneling”) or using SSL (Section 15.8, “OpenSSL”).
Mailboxes may be accessed locally by directly using an MUA on the server on which the mailbox resides. This can be done using a built-in application such as mail(1) or by installing a MUA from the Ports Collection..
All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/doc/
Questions that are not answered by the
documentation may be
sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.