Terminal Email Reader: A Python Automation Project
Introduction
As a student balancing classes, freelance work, and personal tasks, I wanted a way to check my Gmail quickly—without leaving the terminal. So I built a Python script that fetches unread emails and displays them right in the command line, showing the sender, subject, and body.
Thanks to Amazon Q Developer CLI, I streamlined the development process by asking coding questions directly in my terminal. This is my submission for the "Crushing the Command Line" prompt of the Amazon Q Developer "Quack The Code" Challenge.
What My Project Does
This script:
- Logs into Gmail using IMAP with credentials stored securely in a
.env
file - Fetches and decodes unread emails
- Prints cleanly formatted output (sender, subject, and body) in the terminal
- Uses
.gitignore
to exclude sensitive files (like.env
)
How I Used Amazon Q Developer
Amazon Q Developer CLI acted like a coding assistant:
-
Security Setup: Asked how to manage
.env
files safely in Python projects. - IMAP Debugging: Helped troubleshoot email-fetching logic and MIME decoding.
- Code Simplification: Suggested improvements to reduce complexity and improve readability.
Without Q Developer, I’d have spent hours Googling—instead, I got answers right in my terminal.
What I Learned
- How to use IMAP to access Gmail programmatically
- Securing credentials with
python-dotenv
and.gitignore
- Decoding MIME email formats (especially tricky with Gmail’s encoding)
- How powerful Amazon Q Developer is for real-time debugging and learning
How to Run the Script
- Clone the repo:
git clone https://github.com/hann2004/email-automation.git
cd email-automation
-
Set up your
.env
file:
[email protected]
PASSWORD=your-app-password # Generate this in Gmail settings
Note: Never commit .env
to version control.
- Install dependencies:
pip install -r requirements.txt
- Run it:
python email_automation.py
Note: Enable IMAP in Gmail settings and create an App Password if you use 2FA.
GitHub Repository
https://github.com/hann2004/email-automation
Final Thoughts
This project taught me how powerful command-line automation can be—and how tools like Amazon Q Developer make coding faster and more intuitive. Next, I’d love to add features like email filtering or mark-as-read functionality.
Thanks for reading! Feedback is welcome.
Top comments (0)