Start course

This is the fourth of a total of six courses covering the 102 exam of the LPIC-1 Linux Server Professional certification. You'll learn about managing key Linux system services, including:

  • System time: how to stay in sync with Stratum One NTP time servers.
  • Logging: how to use logs to monitor your system for security and performance considerations
  • Email: create and manage email accounts, forwarders, and aliases.
  • Printing: configure and manage printers and print jobs

If you have thoughts or suggestions for this course, please contact Cloud Academy at


Despite many earnest predictions over the years, email use doesn't seem to be in any serious danger of disappearing any time soon. And despite the fact that just about everyone uses sophisticated web-based email servers like Gmail, there's still plenty of demand for locally configured email services. That's why the LPIC still requires that you're at least generally familiar with the four main MTA packages: qmail, Postfix, Sendmail and Exim. Even though qmail is not currently maintained and Exim by reputation isn't as secure as the others, they're among those found in active deployments. MTA, by the way, stands for mail transport agent.

Managing email on Linux

The fact is that while there are many MTA programs available for Linux, for the most part, they're all functionally quite similar. In fact, I believe that they all share a common mail framework, Mailutils. Don't think that there aren't significant differences in policy and behavior between these packages, but they're certainly not important for the LPIC exam. As it happens, we're going to work with Postfix, Ubuntu's default MTA. We'll assume that both the Postfix and mailutils packages have been installed. To send mail from the command line, you use, "sendmail -t" and the name of the recipient. Since in my case Postfix is configured to only work locally, I'll send it to a local user, Tony. You could include a subject line using "Subject:", and then as many lines of text as you need. To save and send your email, type a period on an empty line.

Let's switch users and become Tony to see if the mail has arrived. By the way, all mail messages are kept in files in the /var/mail directory. You can also use aliases to address emails. A mail alias is really just a name that can be invoked to send a single email to multiple recipients. You can create a new alias by editing the /etc/aliases file. By default, you'll generally already have one existing alias, Postmaster, that is mapped to the root user. Let's add a new alias, Developers, which would include all the developers working for our company. To initialize the mail database, we'll need to run "newaliases." Now let's send an email to the whole group.

To make sure it worked, we'll switch users to a different user and check his mail. Well, that worked. By the way, on a normal system you obviously shouldn't be doing quite so much poking around in user accounts. These are all fictional accounts on this LXE virtual machine I created especially for this video. If there is a guy named Frank on my system, I certainly haven't met him.

Besides alias groups, you can also create automatic email forwarders using a ".forward" file in your home directory.

Let's create one for Frank. Notice the dot before the file name. This adds the file attribute, "hidden." We'll now add an email recipient to the file, say, Ubuntu, and log out of Frank's account and into Tony's. There we'll fire off a quick email to Frank, log back into Frank's account to see if there was any mail. Nothing. Now we'll exit a few shells until we get back to Ubuntu and check for new mail there. And he's got new mail, just as we expected.

You should also be aware of the mailq command, which will list all pending messages still waiting to be sent. Our queue is currently empty.

Let's review. You can send email using sendmail adding "-T" and the recipient address. Emails are stored in files in /var/mail. You can add an alias group to the /etc/aliases file and initialize the mail DB using "newaliases." You can create a mail forwarder for an individual user by creating a ".forward" file in his home directory. And mailq will display all emails currently pending.

SES: Amazon's SMTP email service

Like just about everything else, Amazon also does email. AWS has an industrial strength SMTP server for large volumes of outgoing mail called SES, simple email service. SES can handle key tasks like message authentication and programming APIs.

About the Author
Learning Paths

David taught high school for twenty years, worked as a Linux system administrator for five years, and has been writing since he could hold a crayon between his fingers. His childhood bedroom wall has since been repainted.

Having worked directly with all kinds of technology, David derives great pleasure from completing projects that draw on as many tools from his toolkit as possible.

Besides being a Linux system administrator with a strong focus on virtualization and security tools, David writes technical documentation and user guides, and creates technology training videos.

His favorite technology tool is the one that should be just about ready for release tomorrow. Or Thursday.

Covered Topics