Mail transfer agent basics
Mail transfer basics: what an MTA does as distinct from the program a user reads mail in, the aliases and forwarding files, and the queue commands that are the same whichever MTA is installed.
Lesson 3 of 4 in objective 108. Essential system services, part of LPIC-1 Exam 102-500.
The pieces of a mail system
A mail transfer agent moves mail between machines over SMTP. A mail delivery agent puts it into a mailbox, and a mail user agent is what a person reads it with. The MTAs to recognise are sendmail — the original, with a famously difficult configuration — Postfix, which is the common default now, exim, which is Debian's traditional choice, and qmail. What the exam mostly wants is that they are interchangeable at the level of the commands below, because every one of them provides a sendmail-compatible interface.
Local mail matters even on a machine nobody emails: cron sends job output to the owner's mailbox, and so do several system services. That is why an unconfigured MTA leaves surprises in /var/mail or /var/spool/mail.
Aliases and forwarding
/etc/aliases maps a local name to somewhere else: another user, a list of users, a file, or a command through a pipe. It is compiled into a database, so an edit does not take effect until newaliases (or sendmail -bi) is run — which is the single most-asked fact on this objective. The conventional entry is root: someone, so that mail to root reaches a person.
The right-hand side is a comma-separated list, and each member of it may be one of five things: a local user, a full address elsewhere, an absolute path to a FILE the message is appended to, a command prefixed with a pipe, or an :include: reference. The leading pipe is the single character that turns a destination into program delivery, so support: |/usr/local/bin/ticket.sh hands the whole message to a ticketing script on its standard input, while the same line without the pipe would append the message to a file of that name. Because a program alias runs code, the delivery agent runs it as an unprivileged account rather than as root.
:include: is the one worth understanding by its TIMING rather than its syntax. The aliases file is compiled into a database and changes nothing until that database is rebuilt, which needs root; an :include: file is opened and parsed on every delivery. So oncall: :include:/var/lib/oncall/members leaves the membership in a file the team lead owns, editable by them, taking effect on the next message, with no administrator and no newaliases in the loop. That is the standard way to delegate a small list.
~/.forward is the user's own version and needs no rebuilding: a single line naming an address forwards everything. Putting the user's own name in it as well, prefixed with a backslash, keeps a local copy — otherwise forwarding replaces delivery.
The queue is inspected with mailq (or sendmail -bp), which lists what is waiting and why. Mail that cannot be delivered is retried for a period and then bounced.
The queue commands are the part that survives changing MTA, and the reason is worth knowing rather than memorising: every one of them installs the same set of names, so /usr/bin/mailq is a link to whatever the installed MTA provides — Postfix on one machine, exim on the next — and the command a candidate types is identical either way. It is an ordinary user command in /usr/bin because reading the queue needs no privilege; flushing it does. newaliases and sendmail are provided the same way, which is why sendmail -bp works on a machine with no sendmail on it.
ls -l /usr/bin/mailq... /usr/bin/mailq -> /etc/alternatives/mailqmailq-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-A3F19C2A1 512 Mon Aug 3 18:02:11 root@host (connect to mail.example.com: Connection refused) ops@example.comsendmail -bp prints the same thing
Queue, mailbox and log are three different places
A message passes through three locations and a question will offer all three as answers. The QUEUE holds what the MTA still owes — /var/spool/mqueue on a sendmail-derived host — and a message leaves it the moment delivery succeeds. The MAILBOX is where the delivery agent wrote it, and for traditional local delivery that is /var/mail/carol for the account carol, with /var/spool/mail the older path that is usually a link to the same directory. The LOG, /var/log/mail.log or /var/log/maillog, only records that the delivery happened; the message is not in it.
The mailbox format matters because it decides whether that is a file or a directory. In mbox the whole mailbox is ONE file, with messages separated by lines beginning From followed by a space — which is why two writers have to lock it, and why a stray line of body text starting with that word has to be escaped. Maildir is the alternative and stores one file per message in a directory such as ~/Maildir, with new, cur and tmp subdirectories, so no locking is needed. Delivery to a user's home directory rather than to /var/mail is a Maildir convention more often than an mbox one.
mailqMail queue is emptynothing owed, so it has already been deliveredls -l /var/mail/carol-rw-rw---- 1 carol mail 8214 Aug 3 18:02 /var/mail/carolhead -1 /var/mail/carolFrom ops@example.com Mon Aug 3 18:02:11 2026the mbox separator: From, then a space
Worth carrying in
- MTA / MDA / MUA
- Transfers between hosts / delivers to a mailbox / what a person reads with.
- /etc/aliases
- System-wide redirection. Run
newaliasesafter editing. - newaliases
- Rebuild the aliases database. Nothing takes effect until this runs.
- ~/.forward
- Per-user forwarding, no rebuild needed.
- /usr/bin/mailq
- What is queued and why. Same as
sendmail -bp, and provided by whichever MTA is installed. - Postfix / exim / sendmail / qmail
- The four MTAs to recognise by name.
- name: |/path/to/prog
- The leading pipe is what makes it program delivery. Without it the path is a file to append to.
- name: :include:/path
- Read at every delivery, so its owner can edit the list without root and without
newaliases. - /var/mail/user
- The mbox a local delivery lands in.
/var/spool/mqueueis the queue;/var/log/mail.logonly records it.
What the exam does with this
- Editing
/etc/aliaseschanges nothing untilnewaliasesruns.~/.forwardneeds no such step. - Queue, mailbox and log are three different files. A delivered message is in the mailbox and nowhere else.
- root should be aliased to a real person, or nobody ever reads what the system sends.
- Know the MTA/MDA/MUA split — questions describe a job and ask which one does it.
- Objective
- 108. Essential system services
- Share of the exam
- 18.33% (the whole objective)
- Questions in this lesson
- 15
- Signed for by a person
- 0
Partly checked. None of the 15 questions here has been read against the cited source by a person. 15 questions have been checked against their cited clause by an automated pass — which is not the same thing, and is not a signature.
Only questions a person has signed for are used in mock exams here. That is the whole difference between the two kinds of checking above.
How these questions are written — where each question comes from, what the verification ledger records, and what happens when one is found wrong.
Drill this lesson
A lesson is one sitting: the trainer draws a short run from these questions alone and spaces the ones you get wrong.
Practise Mail transfer agent basics
Questions in this lesson
- You added the line `helpdesk: alice, bob` to /etc/aliases, but mail to helpdesk still bounces. What is the most likely reason? machine-checked
- An ordinary user with no administrative rights wants all mail delivered to their account forwarded to an external address. Which mechanism is intended for that? machine-checked
- Type the traditional command, present on Sendmail, Postfix and Exim alike, that lists the messages currently waiting in the local mail queue. machine-checked
- Which of the following are mail transfer agents, that is, programs whose job is to accept and relay mail between systems using SMTP? (Choose three.) machine-checked
- Mail addressed to support on a departmental server must be handed to a ticketing script, which expects to read the whole message on its standard input. Which entry in /etc/aliases arranges that? machine-checked
- A team lead who has no root access must be able to change who receives mail sent to the address oncall, without an administrator being involved each time. Which /etc/aliases entry gives them that, assuming the lead owns the referenced file? machine-checked
- On a sendmail-style system, the user emma wants her incoming mail copied to emma@example.net while a copy is still filed in her own mailbox on this host. Listing her plain login name in the file would send that local copy back through alias and .forward expansion again. Which single line in ~emma/.forward names her local delivery in the form that stops the re-expansion? machine-checked
- You have changed a setting in Postfix's main.cf on a busy server and the change must take effect without the mail system going down even briefly. Type the command, with its subcommand, that makes the running Postfix re-read its configuration files. machine-checked
- A desktop mail client must both hand new messages to the company server and download the messages already waiting in the user's server-side mailbox. Which TWO of the following protocols are used for the download direction rather than for submitting or relaying mail? machine-checked
- Postfix ships a compatibility layer so that administrators and scripts written for Sendmail keep working unchanged. Which THREE of the following command names does Postfix provide for exactly that purpose? machine-checked
- A nightly backup script must mail the contents of /var/log/backup.log to ops@example.com with the subject line Backup report, without any interactive prompting. Which command does that? machine-checked
- A remote site was unreachable for an hour and messages for it accumulated in the local queue. The link is now restored and you do not want to wait for the next scheduled queue run. Which sendmail-emulation command asks the MTA to attempt delivery of the queued messages immediately? machine-checked
- On a host using traditional mbox delivery, a message has been accepted and delivered to the local account carol. In which file does that delivered message now sit? machine-checked
- /etc/aliases contains the line `dave: dave@newjob.example.com`, and at the same time ~dave/.forward on the server contains `\dave`. Mail arrives for dave@thishost. What happens? machine-checked
- A user reports that a message they sent an hour ago never arrived, and the queue listing shows the message is gone. Where should you look next to find out what the MTA did with it? machine-checked
Practise Mail transfer agent basics
The rest of objective 108
- Keeping system time correct
- System logging
- Mail transfer agent basics — you are here
- Printers and printing