Send Email

Note to the Student/Instructor

There several ways to setup a configuration for this project. It all depends on the goals of the class or student.

Questions:

Note: A lab with old obsolete computers running Linux would be great. I'm sure there is a lot of hardware sitting in closets somewhere collecting dust. There are places that would probably donate them just to get rid of them.

The Tale

You are working for company XYZ. You are responsible for writing and maintaining a cron job that runs at midnight. It checks the status of various processes. The last thing the program does is send you an email with the status of each process. (Sometimes detailed status information is written to a file if a problem is detected. Th email will notify the receiver of the file's creation.)

You come in every morning and read the email and see what problems were detected (if any).

If you do not receive an email, the monitoring cron jobs has a problem that you must fix.

Note: this once a day scenario is assumed to be sufficient. However, you may need to check the status more often. You may decide to send a text messages to insure a more intermediate response. (This is not part of this project.)

For this project use SMTP.

Project #1

Write a program that sends yourself an email. Read the email with your normal email client.

The message can be a text string for this project.

Project #2

Write a program that reads a text file and sends it as an email.

Project #3

Read system information and send a summary as an email:

(See the instructor for more information about this project.)

Project #4

Email attachments such as images, pdf files, etc.

Project #5

Write a program to read email messages on a server.

Project #6

Create and test a cron job that sends an email. Perhaps containing some system information (see project #3).

Gmail

Create a Gmail (Google) account
Send Email Using yagmail in Python
Delete your Google Account
Send Emails in Python with Gmail
How to Send Emails in Python with Gmail (Mailtrap)
Gmail help: Sign in with app passwords
How to Use the Gmail SMTP Server to Send Emails for Free
Gmail SMTP Settings (Updated Guide)
yagmail Documentation Release 0.10.189 (pdf)
My Notes on Creating a Google App Account

Links

Simple Mail Transfer Protocol (Wikipedia)
smtplib — SMTP protocol client
Sending mail from Python using SMTP
How to Send an Email in Python (2022)
RFC 5321: Simple Mail Transfer Protocol

Free (and not so free) SMTP Servers

The Four Horsemen of Linux Mail Transfer: Exim, Postfix, Sendmail, and Qmail
Howto install EXIM4 mail server in ubuntu and LinuxMint
3 easy steps to setting up your simple SMTP server
11 Free SMTP Server Solutions for Marketers & Developers (2023)
How To Set Up Your Own Email Server
Free SMTP Server for Testing (14 days free)
Mailtrap (100 emails per month free)
Mailtrap - email testing
Python - aiosmtpd - An asyncio based SMTP server
How to set up your own Docker mail server step by step

Cron Jobs

Setting up a cron job in Windows
How to Automate Tasks with cron Jobs in Linux

Definitions

base64 Base64 is used to encode binary data as printable text. This allows you to
transport binary data over protocols that cannot handle it.
cron job Cron jobs are used to automating tasks that run in the background
periodically. Cron is a time-based task or job organizer in operating systems.
These scheduled jobs or tasks are referred to as cron Jobs.
daemon In computing, a daemon (pronounced DEE-muhn) is a program that runs
continuously as a background process and wakes up to handle periodic service
requests which often come from remote processes.

Daemons are processes that run unattended and usually started when the system
starts, and run until the system stops.
IMAP Internet Message Access Protocol is a protocol for accessing email
from a mail server or service. IMAP allows a client e-mail program to access
remote message stores as if they were local.
MIME (Multipurpose Internet Mail Extensions) is an extension of SMTP. It lets users
exchange different kinds of data files, including audio, video, images, and application
programs using email.

Unlike SMTP, MIME supports sending both ASCII text and non-ASCII data.
For text in character sets other than ASCII, the MIME protocol is required.
POP3 (Post Office Protocol) is an older protocol that was originally
designed to be used on only one computer. Unlike modern protocols that
use two-way synchronization, POP3 only supports one-way email synchronization,
only allowing users to download emails from a server to a client.
protocol In networking, a protocol is a standardized set of rules for formatting
and processing data. Protocols enable computers to communicate with one
another.
SMTP (Simple Mail Transfer Protocol) is used to send and receive email. It primarily sends messages
to a server for forwarding.