Sometimes the hardest part of using email in your Python programs is understanding just how the
email system works in Linux. Knowing what software packages perform what particular tasks is
crucial for getting emails from your Python scripts into your inbox.
One of the main goals of the Linux operating system was to modularize software. Instead of having
one monolithic program handle all the required pieces of a function, Linux developers created
smaller programs that each handle a smaller piece of the total functionality of the system.
This philosophy was also used when implementing the email systems used in Linux systems. In Linux,
email functions are divided into separate pieces, each assigned to a different program. Figure 20.1
shows how most open-source email software modularizes email functions in the Linux environment.
FIGURE 20.1 The Linux modular email environment.
As you can see in Figure 20.1, in the Linux environment, the email process is normally divided into
three functions:
The Mail Transfer Agent (MTA)
The Mail Delivery Agent (MDA)
The Mail User Agent (UA)
The MTA is the core of the Linux email system. It’s responsible for handling both incoming and
outgoing mail messages in the system. It maintains mailboxes for each user account on the system and
can accept messages for each user. If your Raspberry Pi is directly connected to the Internet, it can
also send messages destined for recipients on remote hosts as well.
Closely related to the MTA, the MDA delivers the messages the MTA server receives. The strength
of the MDA is that it’s highly customizable. This is where you can program out-of-office messages or
rules to route incoming messages to different folders in your Inbox.
If you want to support email mailboxes directly on your Raspberry Pi, you have to install at least an
MTA package, and you can optionally install a fancier MDA package. By far the two most popular
MTA email packages that you’ll see in the Linux environment are sendmail and Postfix. As it turns