Skip to main content

PyAlert - Email Notifications with Gmail API

PyAlert is a Python-based notification system that allows you to send emails via the Gmail API with optional file attachments (up to 5MB). It ensures emails are still sent even if the file is too large or missing, with a note included in the message.


Features

  • Send email notifications using Gmail API
  • Attach files up to 5MB
  • Automatically refreshes credentials when expired
  • Error handling for missing or oversized files
  • Includes notes in emails when attachments fail

Installation & Setup

1. Install Dependencies

pip install --upgrade google-auth google-auth-oauthlib google-auth-httplib2 google-api-python-client

2. Enable Gmail API & Get Credentials

  1. Go to the Google Cloud Console.
  2. Create a new project.
  3. Enable the Gmail API.
  4. Create OAuth 2.0 Credentials.
  5. Download credentials.json and place it in your project folder.

Usage

Send a Basic Notification

from pyalert import PyAlert

# Initialize PyAlert
pa = PyAlert(credential="credentials.json", token="token.json")
# Update the sender's address
pa.update_sender("fromsender@gmail.com")
# Update subject line. Default is "PyAlert Notification"
pa.update_subject("New subject")    
# Send an email
pa.push_notification("torecipient@example.com", "Hello! This is a test message.")

Send an Email with an Attachment

pa.push_notification("recipient@example.com", "Here's your report!", "report.pdf")

Send an email-to-text

You can send text messages (SMS) and multimedia messages (MMS) via email using the following carrier gateways. To send a text message via email, use this format:

[10-digit phone number]@[carrier domain]

How It Handles Attachments

Scenario Email Sent? File Attached? Additional Note in Email?
Valid file 5MB Yes Yes No extra note
File is missing Yes No Yes: "File not found."
File is too large (>5MB) Yes No Yes: "File too large."

Disclaimer

This project is provided "as is", without warranty of any kind, express or implied. The author makes no guarantees regarding the accuracy, reliability, or suitability of this software for any particular purpose.

By using this project, you acknowledge that:

  • You are responsible for complying with all applicable laws and regulations, including those related to email-to-text messaging.
  • The author is not liable for any damages, losses, or issues resulting from the use of this software.
  • Carriers may block, delay, or filter messages sent via email-to-text gateways.
  • The gateways listed may change or be discontinued at any time.

Use this project at your own risk. 🚀


License

This project is licensed under the MIT License.


Metadata

Release files for pyalert-gmail 0.1.1

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

Source distribution (sdist)

Source distribution for pyalert-gmail 0.1.1
File Size Uploaded
pyalert_gmail-0.1.1.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyalert-gmail 0.1.1
File Interpreter ABI Platform
pyalert_gmail-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.0 kB

Release files / pyalert_gmail-0.1.1.tar.gz

Download URL pyalert_gmail-0.1.1.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
27ffe54ce42149919449dc438c8f7298aba72dc20bfc3a60db21a0f3ff613e0f
BLAKE2b-256 checksum
How to use checksums
658305c231a2f0e6777609066b4fbda72d7c175de67adf53f313605a49745041
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / pyalert_gmail-0.1.1-py3-none-any.whl

Download URL pyalert_gmail-0.1.1-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7db7b727709e6e2984cbc760a2da0f2b93257124aa27e92142c1c292417d2384
BLAKE2b-256 checksum
How to use checksums
a38142035574d7880549017d388d7e8343cd782acf615602b86506d0ddc9ddea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

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