Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ayushgun/easygmail
A lightweight, minimalistic, and synchronous Python package for quickly sending emails via Gmail.
https://github.com/ayushgun/easygmail
Last synced: about 1 month ago
JSON representation
A lightweight, minimalistic, and synchronous Python package for quickly sending emails via Gmail.
- Host: GitHub
- URL: https://github.com/ayushgun/easygmail
- Owner: ayushgun
- License: mit
- Created: 2024-01-09T01:33:42.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-02-22T15:58:54.000Z (10 months ago)
- Last Synced: 2024-08-01T16:39:49.466Z (4 months ago)
- Language: Python
- Homepage:
- Size: 27.3 KB
- Stars: 130
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- my-awesome-github-stars - ayushgun/easygmail - A lightweight, minimalistic, and synchronous Python package for quickly sending emails via Gmail. (Python)
README
# EasyGmail
## Overview
EasyGmail is a lightweight, minimalistic, and synchronous Python API designed for quick email sending via Gmail.
## Roadmap
The current release is a beta release. By stable release 1.0, the following features are projected to be added:
- [ ] Unit testing
- [ ] Static Site Documentation
- [ ] File Attachments
- [ ] HTML Emails
- [ ] Variadic Recipients## Getting Started
### Installation
```
pip install git+https://github.com/ayushgun/easygmail
```### Prerequisites
Before using EasyGmail, ensure you have an [app password](https://support.google.com/mail/answer/185833?hl=en#app-passwords) for Gmail. Do **not** use your regular account password.
### Quick Start Example
```python
from easygmail import Client, EmailBuilderclient = Client("
@gmail.com", "")msg = EmailBuilder(
receiver="@domain.com", subject="", body=""
).build()client.send(msg)
```### Client Initialization
You can instantiate a `Client` object in two ways:
1. **Direct Credentials**:
Provide email address and app password directly as arguments.```python
from easygmail import Clientclient = Client("
@gmail.com", "")
```2. **Environment File**:
Use a `.env` file to store credentials.```python
from easygmail import Clientclient = Client(env_file=".env")
```Your `.env` file should contain:
```bash
@gmail.com"
EMAIL_ADDRESS="
PASSWORD=""
```### Creating Email Messages
Create `EmailMessage` objects using one of the following methods:
1. **EmailBuilder Constructor**:
```python
from easygmail import EmailBuildermsg = EmailBuilder(
receiver="@domain.com", subject="", body=""
).build()
```2. **EmailBuilder Factory Interface**:
```python
from easygmail import EmailBuildermsg = (
EmailBuilder()
.set_receiver("@domain.com")
.set_subject("")
.set_body("")
).build()
```3. **Directly Using `EmailMessage`**:
```python
from email.message import EmailMessagemsg = EmailMessage()
msg["To"] = "@domain.com"
msg["Subject"] = ""
msg.set_content("")
```