Skip to main content

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.

PyPI Downloads MIT License

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

Release files for PyMailkit 2.0.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 PyMailkit 2.0.1
File Size Uploaded
pymailkit-2.0.1.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PyMailkit 2.0.1
File Interpreter ABI Platform
pymailkit-2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.4 kB

Release files / pymailkit-2.0.1.tar.gz

Download URL pymailkit-2.0.1.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4e60e0b0b8211dc06a033f602c61754801e18fce4628ff44050299045f9bf47b
BLAKE2b-256 checksum
How to use checksums
b68c7d5e6d7ce76dc8c5d988a8b436048b1ced7501d716651d31e7443ea5d0bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.0rc1

Release files / pymailkit-2.0.1-py3-none-any.whl

Download URL pymailkit-2.0.1-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2cac1f858c75e1b16a17c9e765893f3a8c6bc7b5b45589e5016230bce29dd685
BLAKE2b-256 checksum
How to use checksums
777d82a31026bd3b4f1ab118ffca5ff3181f4100aa4d0552532f962813cff1bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.0rc1

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 release files

2.0.0

2 release files

1.0.0

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