A Python package for sending email notifications using the Gmail API.
Project description
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
- Go to the Google Cloud Console.
- Create a new project.
- Enable the Gmail API.
- Create OAuth 2.0 Credentials.
- Download
credentials.jsonand 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyalert_gmail-0.1.1.tar.gz.
File metadata
- Download URL: pyalert_gmail-0.1.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27ffe54ce42149919449dc438c8f7298aba72dc20bfc3a60db21a0f3ff613e0f
|
|
| MD5 |
df766927d5c2010ffde292442809b632
|
|
| BLAKE2b-256 |
658305c231a2f0e6777609066b4fbda72d7c175de67adf53f313605a49745041
|
File details
Details for the file pyalert_gmail-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pyalert_gmail-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7db7b727709e6e2984cbc760a2da0f2b93257124aa27e92142c1c292417d2384
|
|
| MD5 |
32416ed88a7c2f6f5ef506ab6fddbf34
|
|
| BLAKE2b-256 |
a38142035574d7880549017d388d7e8343cd782acf615602b86506d0ddc9ddea
|