Linucate
~ Linucate_

108.3 Mail Transfer Agent Basics

All Levels

Introduction

This lesson is about the basic mail plumbing available on many Linux systems.

The main question is:

What is an MTA, and how do aliases and forwarding work on a Linux host without turning this into a full mail-server lesson?

What you should be able to do after this lesson:

  • Understand what an MTA does.
  • Recognize the names postfix, sendmail, and exim.
  • Understand mail aliases and user forwarding.
  • Use mail, mailq, newaliases, and sendmail-compatible commands at a basic level.
  • Tell the difference between LPIC exam knowledge and full mail-server administration.

Big Idea: The MTA Moves Mail Around

An MTA is a Mail Transfer Agent. Its job is to accept mail and move it toward the next destination.

At beginner level, keep these roles separate:

  • MUA: the mail user agent, such as a mail client
  • MTA: the program that transfers mail
  • aliasing/forwarding: rules that redirect mail locally

For LPIC, you do not need full production mail-server tuning. You need the basic concepts and the simple local tools.

Common MTA Names

You should recognize these names:

  • postfix
  • sendmail
  • exim

In real life, postfix is very common. For the exam, the important part is that all three are MTAs you may encounter.

Local Mail and System Mail

Linux systems often use local mail for:

  • root notifications
  • cron job output
  • automated reports

This is why an MTA still appears in LPIC material even if beginners mostly think about webmail and cloud mail services.

Mail Aliases

An alias maps one local mail name to another destination.

Typical example:

  • mail to root gets redirected to a real admin account

Common alias file:

/etc/aliases

Example idea:

root: admin

After changing aliases, rebuild the alias database:

sudo newaliases

This is one of the most important commands in this objective.

User Forwarding with ~/.forward

A user can forward mail by creating:

~/.forward

Example:

[email protected]

Simple idea:

  • aliases are often system-level
  • .forward is user-level

Sending or Reading Mail

Basic mail tools vary by distribution, but LPIC expects awareness of commands like:

mail
mailq

mail

This can be used to read or send simple text mail on systems where local mail is configured.

mailq

This shows the mail queue. If messages are waiting, they may be listed there instead of already delivered.

Sendmail Compatibility

Many tools use a sendmail-compatible interface even when the actual MTA is not classic Sendmail.

That is why you may see scripts or commands that call:

sendmail

The key beginner idea is:

  • the command interface may be named sendmail
  • the actual MTA behind it may be postfix or another program

A Practical Mental Model

When local mail does not behave as expected, think in this order:

  1. is an MTA installed?
  2. is mail being queued?
  3. does an alias redirect it?
  4. does ~/.forward redirect it?
  5. is the host intended to deliver mail locally only, or also externally?

That is enough reasoning for LPIC-1 level troubleshooting.

Practice Step by Step

1) Check which mail tools exist
  1. Run: command -v mail command -v sendmail command -v postfix command -v exim
  2. Do not worry if some are missing. Different systems install different mail tools.
2) Inspect aliases
  1. If the file exists, run: sudo sed -n '1,80p' /etc/aliases
  2. Look for entries such as root.
  3. If you change aliases on a test system, rebuild them with: sudo newaliases
3) Check the mail queue
  1. Run: mailq
  2. If there are queued messages, note that they are waiting for delivery.
  3. If the queue is empty, that is also normal on many small systems.
4) Inspect user forwarding
  1. Check whether a forward file exists: ls -la ~/.forward
  2. If it exists, view it: cat ~/.forward
  3. This tells you whether local mail for the user is redirected elsewhere.

Cheat Sheet

command -v mail
command -v sendmail
mail
mailq
sudo sed -n '1,80p' /etc/aliases
sudo newaliases
ls -la ~/.forward
cat ~/.forward
🎯

Test Your Knowledge

Complete the quiz to assess your understanding of this course's concepts.