Weight: 3
Goal: Be aware of MTAs on Linux. Manage forwarding and aliases for local users.
The exam expects awareness of the major MTAs, plus practical knowledge of aliases, forwarding, and the mail queue.
A Mail Transfer Agent (MTA) is a server program that sends and receives email between machines using SMTP (Simple Mail Transfer Protocol). It is the postal service of the internet.
Three terms often used together:
| Term | What it does | Example |
|---|---|---|
| MUA (Mail User Agent) | The mail client a user uses to read and write messages. | Thunderbird, Outlook, mutt, mail |
| MTA (Mail Transfer Agent) | Moves mail between servers using SMTP. | Postfix, Sendmail, Exim, qmail |
| MDA (Mail Delivery Agent) | Delivers mail into the user’s mailbox file. | procmail, maildrop, often built into the
MTA |
A typical flow:
MUA ───SMTP──► MTA (sender) ───SMTP──► MTA (recipient) ──► MDA ──► mailbox
Every Linux system traditionally has a local MTA running so that
programs (cron, system warnings, mail from scripts) can
send mail — even if no real email actually leaves the machine.
The exam lists these four by name. You don’t have to configure them — just know which is which.
sendmail.cf is famously unreadable./usr/sbin/sendmail is kept as a
compatibility command name even when another MTA is installed (see “the
sendmail binary” below)./etc/postfix/main.cf and
/etc/postfix/master.cf./etc/exim4/exim4.conf (or
split into pieces under /etc/exim4/conf.d/).To make life easier for programs that send mail, all major MTAs
provide a /usr/sbin/sendmail command that
behaves like the original Sendmail’s submission interface. So whether
the system runs Postfix, Exim, or qmail, scripts and tools (cron, PHP’s
mail(), etc.) can still call sendmail and it
just works.
That’s why the exam says “the sendmail command” — it’s a generic interface, not necessarily the Sendmail MTA.
echo "Subject: Hi
Hello there" | /usr/sbin/sendmail -t alice@example.commail / mailxmail (often a symlink to mailx) is the
simple command-line tool for sending and reading mail.
# Send a simple message
echo "Backup completed" | mail -s "Backup OK" root
# With attachment (depends on implementation)
mail -s "Subject" -a /path/to/file.log user@example.com < body.txt
# Read your own mailbox
mailThis is the same command introduced in objective 105.2 (scripting). For the exam, remember:
-s "Subject" sets the subject./etc/aliases/etc/aliases redirects mail addressed to a local
username to one or more other destinations. It is the standard
way to do site-wide redirection.
Format — one alias per line, name: destination:
# /etc/aliases
# Required: redirect root's mail to a real human
root: alice
# Forward mail to multiple users
sysadmins: alice, bob, carol
# Forward to an external address
webmaster: admin@example.com
# Pipe to a program (note the leading | inside the quotes)
support: "|/usr/local/bin/ticket-import"
# Read recipients from a file
allstaff: :include:/etc/mail/staff-list
# Redirect to a file (mail is appended to it)
archive: /var/mail/archive
# Chain: support → helpdesk → multiple users
support: helpdesk
helpdesk: alice, bob
Right-hand side options:
| Form | Meaning |
|---|---|
username |
Deliver to local user. |
user@host |
Deliver to remote address. |
/path/file |
Append message to a file. |
|command |
Pipe message into a command (must be quoted, often with the leading
| inside quotes). |
:include:/path |
Read additional recipients from that file. |
newaliases —
rebuild the databaseThe MTA doesn’t read /etc/aliases directly at delivery
time. It reads a hashed database built from it, usually
/etc/aliases.db. After editing /etc/aliases,
you must run:
newaliasesOn Postfix this is equivalent to postalias /etc/aliases.
On Sendmail it runs sendmail -bi. Forgetting
newaliases is a classic exam trap.
~/.forwardA user can redirect their own incoming mail without root’s help by
creating a file ~/.forward in their home directory.
Format — one destination per line (same right-hand-side options as
/etc/aliases):
# ~/.forward
alice@gmail.com
\alice # also keep a local copy (backslash prefix)
"|/usr/local/bin/spam-filter"
Key points:
.forward automatically on every delivery.
No need to rebuild any database..forward if it’s
owned by the user and not world-writable.\ to also
keep a local copy in addition to the forward.~/.forward is the per-user counterpart
to the system-wide /etc/aliases.
When an MTA can’t deliver a message immediately (remote server down, etc.), it stores it in a queue and retries later. You can inspect and manage this queue.
mailq # show the mail queue (works with all MTAs)
sendmail -bp # same — equivalent to mailqOutput shows each queued message, its size, age, and recipient.
postqueue -p # equivalent of mailq
postqueue -f # FLUSH the queue (try delivery now)
postsuper -d ALL # DELETE all messages from the queue
postsuper -d <queue-id> # delete one messagesendmail -q forces a queue
run; the queue files live under /var/spool/mqueue/.exim -bp lists,
exim -M <id> forces delivery,
exim -Mrm <id> removes a message. Queue lives under
/var/spool/exim4/input/ (Debian) or similar.For the exam, the universal commands are mailq and
sendmail -bp.
Where the actual user mail is stored depends on the MTA/MDA, but two formats dominate:
| Format | Location | Structure |
|---|---|---|
| mbox | /var/mail/<username> or
/var/spool/mail/<username> |
All messages concatenated into a single file. |
| Maildir | ~/Maildir/ (with subdirs new/,
cur/, tmp/) |
One file per message. More robust under concurrency. |
You only need to recognize both names — the exam doesn’t go deeper.
MTAs to recognize:
Files:
/etc/aliases — system-wide aliases./etc/aliases.db — hashed binary version, rebuilt by
newaliases.~/.forward — per-user forwarding./var/mail/<user> or
/var/spool/mail/<user> — mbox mailboxes.~/Maildir/ — Maildir mailboxes.Commands:
mail / mailx — send and read mail.sendmail — the universal submission binary.newaliases — rebuild the aliases database.mailq (or sendmail -bp) — display the mail
queue.postqueue, postsuper
(Postfix-specific).Name the four MTAs the LPIC-102 objective lists. Sendmail, Postfix, Exim, qmail.
What is the difference between an MTA and an MUA? An MTA (Mail Transfer Agent) is a server that transports mail between machines via SMTP. An MUA (Mail User Agent) is the client a user uses to read and compose mail.
What does /usr/sbin/sendmail do on a system
running Postfix? It is a compatibility command. Postfix
provides its own sendmail binary so that scripts and
applications written against the Sendmail interface work
unchanged.
Where do system-wide mail aliases live?
/etc/aliases.
What command must you run after editing
/etc/aliases, and why? newaliases.
The MTA reads a binary, hashed database (/etc/aliases.db)
built from the text file — it doesn’t see your edits until you rebuild
it.
How do you forward all root’s mail to user
alice? Add root: alice to
/etc/aliases, then run newaliases.
How can a user redirect their own incoming mail without
root’s involvement? By creating a ~/.forward file
containing the destination address(es).
What is the difference between /etc/aliases
and ~/.forward? /etc/aliases is a
system-wide file, edited by root, that requires newaliases
to take effect. ~/.forward is per-user, lives in the user’s
home, and the MTA reads it automatically without needing a database
rebuild.
In /etc/aliases, what does this entry mean:
support: "|/usr/local/bin/ticket-import"? Every
mail addressed to support is piped into the program
/usr/local/bin/ticket-import on standard input.
In a .forward file, what does
\alice mean? Deliver a copy to the local user
alice in addition to the other listed
destinations. The backslash prevents further alias expansion.
What command shows the mail queue, regardless of the MTA
in use? mailq (equivalent to
sendmail -bp).
What is the Postfix command to flush the queue and try to
deliver everything now? postqueue -f.
What is the typical location of an mbox mailbox?
/var/mail/<username> or
/var/spool/mail/<username>.
Where is a Maildir mailbox typically located, and what
subdirectories does it contain? Under the user’s home
directory, often ~/Maildir/, with three subdirectories:
new/, cur/, and tmp/.
Why is it common to alias root to a real
user? Cron jobs, system warnings, and many daemons mail root by
default. Aliasing root to a human ensures someone actually sees those
messages.