A modern Python library for sending and receiving emails with SMTP and IMAP support
Project description
PyMailkit
PyMailkit is a lightweight Python library designed to simplify sending and receiving emails. It provides an easy-to-use interface for interacting with email servers, making it ideal for automation, notifications, and email-based workflows.
Project Structure
- Send emails with attachments and custom headers
- Fetch and filter emails from your inbox
- Simple authentication using app passwords
- Minimal dependencies and easy setup
PyMailkit/
├── LICENSE
├── pyproject.toml
├── README.md
├── setup.py
└── src/
└── pymailkit/
├── __init__.py
├── auth.py
├── receiver.py
├── sender.py
└── tests/
├── test_receiver.py
└── test_sender.py
Installation
Install PyMailkit with pip:
pip install PyMailkit
Modules
1. Sender Module (pymailkit.sender)
The sender module allows you to send emails easily, including support for attachments and custom subjects/bodies.
Key Features:
- Send plain text or HTML emails
- Add attachments
- Specify sender, recipients, subject, and body
Example:
from pymailkit.sender import EmailSender
# Initialize the email sender
mail_server = EmailSender()
# Connect to your email account (prompts for app password)
mail_server.connect(username="example@gmail.com")
# Email details
from_add = "fromsomeone@gmail.com"
to_add = "tosomeone@gmail.com"
sub = "Sample Subject"
body = "Sample body for email sending example"
# Send the email
mail_server.send_email(
to_addresses=to_add,
from_address=from_add,
subject=sub,
body=body,
attachments = "/content/sample_data/mnist_test.csv" # Provide absolute path
)
# Close the connection to the server
mail_server.close()
2. Receiver Module (pymailkit.receiver)
The receiver module lets you fetch emails from your inbox, with options to limit the number of emails and filter by criteria.
Key Features:
- Fetch emails from inbox
- Limit number of emails retrieved
- Access email metadata (subject, sender, date, body)
Example:
from pymailkit.receiver import EmailReceiver
# Initialize the email receiver
mail_server = EmailReceiver()
# Connect to your email account (prompts for app password)
mail_server.connect(username="example@gmail.com")
# Fetch the latest 3 emails
emails = mail_server.fetch_emails(limit=3)
# Print subjects of fetched emails
for email in emails:
print(email['subject'])
# Close the connection to the server
mail_server.close()
Authors
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 pymailkit-2.0.1.tar.gz.
File metadata
- Download URL: pymailkit-2.0.1.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.0rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e60e0b0b8211dc06a033f602c61754801e18fce4628ff44050299045f9bf47b
|
|
| MD5 |
1059bf34062dc29056df79badb5af9d7
|
|
| BLAKE2b-256 |
b68c7d5e6d7ce76dc8c5d988a8b436048b1ced7501d716651d31e7443ea5d0bb
|
File details
Details for the file pymailkit-2.0.1-py3-none-any.whl.
File metadata
- Download URL: pymailkit-2.0.1-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.0rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cac1f858c75e1b16a17c9e765893f3a8c6bc7b5b45589e5016230bce29dd685
|
|
| MD5 |
608d8168ab59b9067b95f4be7bc97450
|
|
| BLAKE2b-256 |
777d82a31026bd3b4f1ab118ffca5ff3181f4100aa4d0552532f962813cff1bb
|