One of the first things every FreeBSD user wishes to configure on his computer is e-mail access. However, a look in the mail section of the ports collection yields an amazing 148 applications dealing with e-mail. To make matters worse, some claim to be MUAs, MTAs, POP3 clients, or IMAP4 servers. These descriptions are not helpful if you are unfamiliar with these terms and just want to be able to send and receive e-mail.
In this article, I'll give a "readers digest" version of some important e-mail concepts, with references to additional information. Then I'll walk you through the steps of configuring your FreeBSD system to send and retrieve e-mail, as well as configuring Pine.
Ever since networks were invented, people have wanted a method of sending messages to each other. This led to the development of many messaging programs, most of which were proprietary, meaning you could only send a message to someone who used the same messaging system. Early messaging systems allowed you to send a message directly to another person's computer. However, this method doesn't work if the other computer is turned off or there is a problem with the physical connection between the two computers.
Most messaging systems prefer to have all users send their messages to a centralized server for storage; since this server is always available, it can act like a post office. If a user has a mailbox on that server, he can periodically check his mailbox to see if he has received any messages.
As the need for messaging grew, standards were developed to allow users to send messages to any user, regardless of the messaging system they used. One of these standards was X.400; another was SMTP, which became the standard used on the Internet. Two interesting points of views on these standards can be found at X.400 - The Better Internet and X.400 is Dead, Long Live X.400.
Unless you work at a company that uses an internal X.400 messaging system,
you probably use SMTP to send e-mail. The e-mail addresses you are used to
seeing are actually SMTP addresses and look like this:
email@example.com You'll note that an SMTP address looks similar to a web address, except it has a
@ instead of the first period. The Internet already uses DNS (the Domain Name System) to locate a computer's IP address. When an administrator sets up a mail server, he will create an MX (mail exchange) record in his DNS database to indicate which computer in his network is the mail server. The name to the left of the @ indicates the name of a user's mailbox on that mail server.
When the Internet messaging standard was being developed, it was decided to use the centralized server (post office) approach where users would check their mailboxes. The Internet uses TCP/IP, so new TCP/IP protocols needed to be created. Remember from last week that protocols define the rules of communication and that each TCP/IP protocol has an associated port number and at least one RFC which describes its operation.
SMTP (simple mail transfer protocol) describes the communications between mail servers. Its port number is 25, and its behavior is described in RFC 821.
As its name implies, SMTP merely transfers mail from one server to another until it reaches the correct mail server. In order to ensure that the message makes it into the right mailbox on that server, POP3 (post office protocol 3) is used. POP3 uses port number 110 and is defined by RFCs 1734, 1957, 2449, and STD0053 (standard 53).
POP3 is also responsible for the management of the mailboxes on a mail server. POP3 will not let a user retrieve the messages in their mailbox until they have been authenticated.
If you are unfamiliar with the commands used by POP3 and SMTP, try the SMTP with Telnet tutorial.
This tutorial shows how you yourself can issue SMTP and POP3 commands to send and receive e-mail. These are the same commands that are usually issued by messaging systems and e-mail programs.
One other term you may come across is IMAP4 (Internet Message Access Protocol version 4). IMAP4 is similar to POP3, but with extra features. POP3 assumes that a user will download all of the mail in their mailbox so the copy on the mail server can be deleted; the user will then disconnect from the mail server to read his e-mail "offline." With IMAP4, a user can download just the headers of his e-mail so he can decide which messages he wants to retrieve at this time; he can also delete messages directly at the mail server without having to download them first.
Messaging software is usually divided into two separate components: the MTA (message transfer agent) and the MUA (message user agent). The MTA runs on the mail server and understands both SMTP and POP3. Therefore, it is able to send messages to other SMTP mail servers, receive messages from other SMTP mail servers, and store messages in the appropriate user mailboxes. Sendmail is the most common MTA in use on the Internet and comes bundled and ready to go on your FreeBSD system. Exim, Postfix, and Qmail are examples of other MTAs that you can build using FreeBSD's ports collection.
The MUA is used by users to compose and read e-mail messages. Some MUAs have a POP3 client built-in, meaning you can check for new mail using the MUA; some do not, and will only display e-mail you've retrieved using a separate POP3 client. MUAs differ widely in their features; which MUA to use is a matter of personal preference. There are dozens of MUAs in the ports collection; some of the most popular are Mutt, Pine, and Xfmail.
So, how do all these components work together when you send an e-mail message? You use your MUA (for example, Pine) to create an e-mail message; Pine will pass the message to the MTA (Sendmail), who will query DNS to find the address of the SMTP server hosting the mailbox of the user you are sending the message to. Sendmail will then use SMTP commands to transfer the message to that mail server. That mail server will use POP3 to put the message in the correct mailbox. Your recipient will use POP3 commands to retrieve the message and will use their favorite MUA to read the message and possibly compose a reply to it.
Let's look at the configuration of a FreeBSD system that will be using Sendmail (the MTA), fetchmail (the POP3 client), and Pine (the MUA). Let's assume a very quick and dirty scenario in which I have one user on a single FreeBSD computer who wishes to use e-mail.
Like any MTA, Sendmail is a highly configurable and complex program capable of providing messaging for large companies and even ISPs. However, you don't want to start messing with the default Sendmail configuration files unless you know what you're doing. If you ever need to get into more complicated Sendmail configurations, you should first read the book sendmail, 2nd Edition by Brian Costales and Eric Allman. You may also wish to investigate other alternatives such as Qmail or Exim.
Fortunately, the default Sendmail configuration on your FreeBSD system will issue SMTP commands so you can send out e-mail to the world. Sendmail is enabled by default; if you want to double-check that you haven't disabled it at some point, issue the following command:
more /etc/defaults/rc.conf | grep sendmail
sendmail_enable="YES" # Run the sendmail daemon (or NO). sendmail_flags="-bd -q30m" # Flags to sendmail (if enabled)
sendmail_enable line is set to
"NO", you'll have to become the superuser to change it to
"YES" using your favorite text editor. Be sure to check your change carefully for typos before saving the file. While you're still the superuser, close all programs running on the computer and issue the following from the Alt-F1 terminal:
When you receive a prompt, press the Enter key, then type:
Watch the messages that appear on the screen; you should see a line similar to this:
starting standard daemons: sendmail.
Now that your MTA is running, you'll want to build the MUA. If you have installed the ports collection on your computer, become the superuser and:
cd /usr/ports/mail/pine4 make && make install
When that is finished, you'll also want to build the POP3 client so:
cd ../fetchmail make && make install
If you don't use the ports collection, both Pine and Fetchmail have packages that can be downloaded from FreeBSD Ports.
Save the downloaded packages to this directory, then:
cd /usr/packages pkg_add pine* pkg_add fetc*
Pages: 1, 2