Ever wanted to send a regular newsletter without lifting a finger? Here’s how you can build a fully automated email newsletter using:
Python
Gmail
GitHub Actions
Tools You’ll Need
A Gmail account (preferably a new one)
Basic knowledge of Python
A GitHub account
Step 1: Set Up Gmail
Create a new Gmail account.
Enable “Less secure apps” to allow login via script.
Store your email and password securely in a
.env
file (we’ll cover that next).
Step 2: Prepare Your Python Script
Create a folder called
automated-newsletter/
Inside it, create two files:
.env
– for your credentialsnewsletter.py
– for the script
.env
file format:
⚠️ Important: Never commit
.env
to GitHub!
Step 3: Install Required Libraries
Step 4: Write the Python Script
Here’s a full working version of the script:
Step 5: Automate with GitHub Actions
Create the following folder structure:
Paste this into
newsletter.yml
:
Go to your GitHub repo → Settings → Secrets and variables → Actions → New repository secret.
Add:
EMAIL_ADDRESS
EMAIL_PASSWORD