Skip to main content

Gmail Automation Bot

A lightweight Python library for creating automated email response systems using Gmail. This bot monitors your Gmail inbox for new messages and responds to them automatically using a custom response function.

Features

  • 🔄 Continuous email monitoring
  • ✨ Automatic responses to new emails
  • 🚫 Built-in filtering for system emails
  • 🔒 Secure authentication using Gmail App Passwords
  • 📝 Customizable response function
  • 🎯 Smart email threading with proper subject prefixing
  • 💫 Beautiful terminal spinner animation during execution

Installation

pip install imaplib email smtplib

Quick Start

from gmaillite import GmailAutomation

def response_func(subject, body):
    # Define your custom response logic here
    response = f"This is an automated response to your email: {body}"
    return response

# Initialize the bot with your credentials
gmail = GmailAutomation(response_func)

# Start the bot
gmail.start()

Configuration Options

GmailAutomation(
    response_func,                          # Your custom response function
    email_address='your.email@gmail.com',   # Gmail address
    app_password='your-app-password'        # Gmail App Password
)

Starting the Bot

# Start with default 2-second check interval
gmail.start()

# Or specify custom check interval (in seconds)
gmail.start(sleep_time=5)

Custom Response Function

The response function receives two parameters:

  • subject: The email subject
  • body: The email body

Example:

def response_func(subject, body):
    if "urgent" in subject.lower():
        return "I'll process your urgent request soon!"
    return f"Thank you for your email about: {subject}"

Features in Detail

Email Filtering

The bot automatically filters out system emails from:

  • noreply addresses
  • Google Community Team
  • Google Play notifications
  • Other automated system notifications

Logging

Built-in logging system with:

  • Info level logging for successful operations
  • Error level logging for issues
  • Debug level logging for system email filtering

Error Handling

Robust error handling for:

  • Email connection issues
  • Authentication problems
  • Message processing errors

Security Notes

  • Never commit your email credentials to version control
  • Always use App Passwords instead of your main Gmail password
  • Consider storing credentials in environment variables

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For issues and feature requests, please open an issue on the GitHub repository.

Metadata

Release files for gmaillite 0.2.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gmaillite 0.2.12
File Size Uploaded Provenance
gmaillite-0.2.12.tar.gz 4.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for gmaillite 0.2.12
File Interpreter ABI Platform
gmaillite-0.2.12-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 9.4 kB

Release files / gmaillite-0.2.12.tar.gz

Download URL gmaillite-0.2.12.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
cce4877b06d6df8130b1fec623e6879559a037acbc6e94b451b21023d752d6a1
BLAKE2b-256 checksum
How to use checksums
5fa09278528a26c4fa0752240436496a7e6d4b7176cd129c9eec3923d8cadd32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.11.0rc1 Linux/6.8.0-49-generic

Release files / gmaillite-0.2.12-py2.py3-none-any.whl

Download URL gmaillite-0.2.12-py2.py3-none-any.whl
Size 5.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
47481c1cf5101154845905415f2972cecfd576dbe1bfe348c7fa9f3b6c7eeaf2
BLAKE2b-256 checksum
How to use checksums
4d3098252b9cb55a90683cad320c2fcd2bf34a726e9a358fa0e00b8d4e7b5845
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.11.0rc1 Linux/6.8.0-49-generic

Security for gmaillite 0.2.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page