A Python script for sending emails through Gmail, with support for attachments.
Welcome to the Gmail CLI Utilities repository. This repository contains tools for reading and sending Gmail messages via command line interfaces (CLIs). Below is a detailed guide on how to use each tool and additional information on setup and usage.
This repository includes tools for interacting with Gmail through the command line. The tools are organized into two main categories: ReadGmail and SendGmail. Each category contains a README file and corresponding Python scripts.
To use these tools, you need to configure environment variables. The required variables include:
EMAIL_USER: Your Gmail addressEMAIL_PASS: Your Gmail password (use an App Password if two-factor authentication is enabled)
Create a .env file in the root of the directory with the following structure:
EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_app_passwordEnsure this file is correctly placed and not shared publicly.
To use Gmail with these scripts, you must generate an App Password. This is especially important if you have two-factor authentication enabled. Follow these steps:
- Go to your Google Account settings.
- Navigate to Security and find the App passwords section.
- Create a new App Password, which will be displayed as a 16-character string. It should be divided into 4 groups of 4 characters (e.g.,
abcd-efgh-ijkl-mnop).
Use this App Password in the .env file instead of your regular Gmail password.
This directory contains tools for reading Gmail messages from the command line.
This file provides detailed instructions on how to use the read_gmail_cli.py script. It covers setup, usage, and troubleshooting tips. Refer to this document for comprehensive guidance.
This script allows you to read emails from your Gmail inbox. It connects to Gmail via IMAP, fetches messages, and displays them in the terminal. You can specify filters to search for specific messages.
This directory contains tools for sending emails via Gmail from the command line.
Provides instructions for the send_cli_gmail1.py script, detailing how to send emails with subject and body from the CLI.
A script for sending simple text emails. It prompts the user for the recipient's email address, subject, and message body, then sends the email via Gmail's SMTP server.
This document explains the usage of send_cli_gmail2.py, including how to attach files and send emails with attachments.
Similar to send_cli_gmail1.py but with additional functionality for sending emails with attachments. Users can specify a file path to attach to the email.
- Always keep your
.envfile secure and do not share it publicly. - For more detailed information, refer to the specific README files in each subdirectory.
This structure ensures a clean and organized master README, directing users to specific sub-README files for more details and providing essential setup instructions. Let me know if there's anything specific you'd like to add or modify!
You can easily customize the email subject and body by modifying the subject and body variables in the script.
- Never commit your
.envfile to version control. Add it to your.gitignorefile to prevent accidental commits. - Use an App Password instead of your main Gmail password for added security.
- Ensure your email credentials are kept confidential.
If you encounter issues:
- Check that your Gmail account settings allow for less secure app access or that you're using a valid App Password.
- Verify that your
.envfile is correctly formatted and contains the right credentials. - Ensure you're not being blocked by any firewall or antivirus software.
Contributions, issues, and feature requests are welcome! Feel free to check issues page.
Distributed under the MIT License. See LICENSE for more information.
Your Name - rangersmyth.74@gmail.com
Project Link: https://github.com/davidtkeane/gmail_single_cli/
Made with ❤️ by David