Postfix Mail Server Training: by Suresh Chandra
Postfix Mail Server Training: by Suresh Chandra
Postfix Mail Server Training: by Suresh Chandra
Training
By
Suresh Chandra
Introduction
Internet email history goes back as far as the early 1970s, when the
first messages were sent across the Arpanet, the predecessor of
todays Internet.
Since that time, email has been, and continues to be, the most
widely used application on the Internet.
In the olden days, email delivery was relatively simple, and
generally consisted of moving mail files from one large host
to another large host that served many users.
As the Internet evolved and the network itself became more
complex, more flexible tools were needed to move mail
between different networks and different types of networks.
2
Introduction
Introduction
Today, most Internet sites use the SMTP mail protocol to deliver
and receive mail messages.
Sendmail is still one of the most widely deployed SMTP servers,
but there have been problems with it.
Sendmails monolithic architecture has been the primary cause of
numerous security issues, and it can be difficult to configure
and maintain.
Introduction
There were certain goals from the beginning that drove the design
and development of Postfix:
1. Reliability
2. Security
3. Performance
4. Flexibility
5. Ease-of-use
6. Compatibility with Sendmail
Reliability:
Postfix shows its real value when operating under stressful
conditions. Even within simple environments, software can
encounter unexpected conditions.
For example, many software systems behave unpredictably when
they run out of memory or disk space.
Postfix detects such conditions, and rather than make the problem
worse, gives the system a chance to recover. Regardless of
hazards thrown its way, Postfix takes every precaution to
function in a stable and reliable way.
8
Security:
Postfix assumes it is running in a hostile environment. It employs
multiple layers of defense to protect against attackers.
The security concept of least privilege is employed throughout the
Postfix system, so that each process, which can be run within
an isolated compartment, runs with the lowest set of privileges
it needs.
Processes running with higher privileges never trust the
unprivileged processes. Likewise, unneeded modules can be
disabled, enhancing security and simplifying an installation.
9
Performance:
Postfix was written with performance in mind and, in fact, takes
steps to ensure that its speed doesnt overwhelm other
systems.
It uses techniques to limit both the number of new processes that
have to be created and the number of filesystem accesses
required in processing messages.
10
Flexibility:
The Postfix system is actually made up of several different
programs and sub-systems. This approach allows for great
flexibility.
All of the pieces are easily tunable through straightforward
configuration files.
11
Ease-of-use:
Postfix is one of the easier email packages to set up and
administer, as it uses straightforward configuration files and
simple lookup tables for address translations and forwarding.
The idea behind Postfixs configuration is the notion of least
surprise, which means that, to the extent its possible, Postfix
behaves the way most people expect.
When faced with design choices, Dr. Venema has opted for the
decision that seems most reasonable to most humans.
12
14
Email Components
When you tell your MUA to send a message, it simply hands off
the message to a mail server running a mail transfer agent
(MTA).
MTAs (like Post-fix) do the bulk of the work in getting a message
delivered from one system to another.
ail message, the MTA determines if it should take the message or
not.
16
Email Components
An MTA generally accepts messages for its own local users; for
other systems it knows how to forward to; or for messages
from users, systems, or networks that are allowed to relay mail
to other destinations.
Once the MTA accepts a message, it has to decide what to do with
it next. It might deliver the message to a user on its system, or
it might have to pass the message along to another MTA.
Messages bound for other networks will likely pass through
many systems.
If the MTA cannot deliver the message or pass it along, it bounces
the message back to the original sender or notifies a system
administrator.
17
Email Components
18
20
Prerequisites
Unix Topics
Postfix is very much a Unix program working in conjunction with
the underlying operating system for many of its functions.
If youre new to Unix, you should study an introductory text.
21
Prerequisites
Login Names and UID Numbers
The list of recognized users on a system is stored in the
/etc/passwd file.
Every user should have a unique login name and user ID number
(commonly written as uid or UID).
The UID, not the users login name, is the important attribute for
identity and ownership checks.
The login name is a convenience for humans, and the system uses
it primarily to determine what the UID is.
Some Postfix configuration parameters require UIDs rather than
login names when referring to user accounts.
22
Prerequisites
Pseudo-Accounts
A pseudo-account is a normal Unix system account except that it
does not permit logins.
These accounts are used to perform administrative functions or to
run programs under specific user privileges.
Your system most likely came installed with several pseudoaccounts.
23
Prerequisites
24
Prerequisites
The Superuser
The administrative login on Unix systems is the root account.
It is also referred to as the superuser account, and you should treat
it carefully.
You should log in as the root user only when its privileges are
required to accomplish a particular task.
Administering Postfix sometimes requires root privileges.
If you do not have superuser access on your system, you cannot
administer Postfix.
25
Prerequisites
Command Prompts
When working with an interactive shell, you are normally greeted
with a command prompt that indicates the system is ready for
you to enter a command.
26
27
28
Postfix Components
Postfix Components
The master daemon is started first, and it invokes most other
processes, as needed.
Postfix daemons that are invoked by the master daemon process
their assigned tasks and terminate.
They might also terminate after a configured amount of time or
after handling a maximum number of requests.
The master daemon is resident at all times, and gets its
configuration information at startup from both main.cf and
master.cf.
30
Postfix Components
31
New messages can arrive into the Postfix system in three ways.
1. SMTP
2. QMQP Submission Protocol
3. local submission
QMQP: Quick Mail Queueing Protocol
32
What is QMQP?
33
36
37
38
39
The queue manager also has the responsibility of working with the
bounce and defer daemons to generate delivery status reports
for problem messages to be sent back to the sender.
41
The queue manager is responsible for all messages from the point
when the cleanup daemon hands them over until they are
removed from the queue.
The removal can be either because they have been successfully
delivered to all recipients or because they have been in the
queue for so long that Postfix decides that they are
undeliverable.
42
43
Message delivery
Postfix comes with a number of delivery agents that are used to
deliver messages using various means and protocols.
Postfix uses the concept of address classes when determining
which destinations to accept for delivery and how the delivery
takes place.
The main address classes are local, virtual alias, virtual mailbox,
and relay.
Destination addresses that do not fall into one of these classes are
delivered over the network by the SMTP client.
The delivery agents are the last daemons that touch the messages
before they leave your system.
48
Local Delivery
The local delivery agent handles mail for users with a shell
account on the system where Postfix is running.
Domain names for local delivery are listed in the mydestination
parameter.
Messages sent to a user at any of the mydestination domains are
delivered to the individual shell account for the user.
In the simple case, the local delivery agent deposits an email
message into the local message store. It also checks aliases
and users .forward files to see if local messages should be
delivered elsewhere.
49
51
Relay Messages
52
Message delivery
54
55
Supporting programs
56
Supporting programs
57
Supporting programs
58
Lookup tables
59
Lookup tables
60
Lookup tables
61
62