DobyEmail
DobyEmail is a comprehensive Python package for handling various email operations. It provides a set of utilities and classes to simplify email-related tasks in your Python projects.
Features
DobyEmail offers the following key functionalities:
- Email Service: A high-level
Serviceclass that encapsulates SMTP and IMAP operations for sending and receiving emails. - Email Sending: The
Senderclass provides methods for composing and sending emails, including support for attachments. - Email Reading: The
Readerclass allows you to connect to an IMAP server, fetch emails, and parse their content. - Email Transfer: The
Transferclass facilitates moving emails between different email accounts or folders. - Date Parsing: The
parse_datefunction helps in converting various date string formats to a standardized format. - Port Checking: The
check_portsfunction allows you to verify if specific ports are open on a given host. - Email Validation: The
is_valid_emailfunction provides basic validation for email addresses. - Email Port Configuration: The
get_email_portsfunction retrieves standard email port configurations.
Installation
pip install dobyemail
Usage Examples
Using the Service class
from dobyemail import Service, config
service = Service(
smtp_server=config.smtp_server,
smtp_port=config.smtp_port,
smtp_use_tls=config.smtp_use_tls,
imap_server=config.imap_server,
imap_port=config.imap_port,
imap_use_ssl=config.imap_use_ssl,
username=config.username,
password=config.password
)
# Send an email
service.send_email("recipient@example.com", "Test Subject", "This is a test email.")
# Read emails
emails = service.read_emails(limit=5)
for email in emails:
print(f"From: {email['from']}, Subject: {email['subject']}")
Using the Sender class directly
from dobyemail import Sender
sender = Sender(
smtp_server="smtp.example.com",
smtp_port=587,
use_tls=True,
username="your_username",
password="your_password"
)
# Send a simple email
sender.send_email("recipient@example.com", "Hello", "This is a test email")
# Send an email with attachment
sender.send_email(
"recipient@example.com",
"Email with Attachment",
"Please find the attached document.",
attachments=["path/to/document.pdf"]
)
Using the Reader class directly
from dobyemail import Reader
reader = Reader(
imap_server="imap.example.com",
imap_port=993,
use_ssl=True,
username="your_username",
password="your_password"
)
# Read the latest 10 emails
emails = reader.read_emails(limit=10)
for email in emails:
print(f"Subject: {email['subject']}, From: {email['from']}")
# Search for emails with a specific subject
search_results = reader.search_emails("subject", "Important Meeting")
for email in search_results:
print(f"Found email: {email['subject']}")
Using the Transfer class
from dobyemail import Transfer, Reader, Sender
source_reader = Reader(
imap_server="source_imap.example.com",
imap_port=993,
use_ssl=True,
username="source_username",
password="source_password"
)
destination_sender = Sender(
smtp_server="dest_smtp.example.com",
smtp_port=587,
use_tls=True,
username="dest_username",
password="dest_password"
)
transfer = Transfer(source_reader, destination_sender)
# Transfer the latest 5 emails
transferred_emails = transfer.transfer_emails(limit=5)
print(f"Transferred {len(transferred_emails)} emails")
Utility Functions
from dobyemail import parse_date, check_ports, is_valid_email, get_email_ports
# Parse a date string
print(parse_date("2023-05-15")) # Output: "15-May-2023"
# Check if ports are open
print(check_ports("example.com", [80, 443]))
# Validate an email address
print(is_valid_email("user@example.com")) # Output: True
# Get standard email ports
print(get_email_ports())
Running Tests
To run the unit tests, use the following command from the project root directory:
python -m unittest discover tests
Configuration
The email_ports.json file is used for configuring email ports. It is loaded automatically by the Config class in config.py. You can modify this file to add or update email port configurations.
Contributing
Please read CONTRIBUTE.md for details on our code of conduct, and the process for submitting pull requests and publishing to PyPI.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Metadata
Release files for dobyemail 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dobyemail-0.1.6.tar.gz | 18.3 kB | Without provenance | Details for dobyemail-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dobyemail-0.1.6-py3-none-any.whl | Python 3 | none | any | Details for dobyemail-0.1.6-py3-none-any.whl |
Total release size: 34.5 kB
Release files / dobyemail-0.1.6.tar.gz
| Download URL | dobyemail-0.1.6.tar.gz |
|---|---|
| Size | 18.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e5dac18d6fd47696ce8c6c1ce3c048b07ac6334f747462821d93a9dc0abc5df0
|
|
BLAKE2b-256 checksum How to use checksums |
6047184ec9bc9b041262d43bd1c9b08d2b3336b262114ee0ec7042f37f29c102
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / dobyemail-0.1.6-py3-none-any.whl
| Download URL | dobyemail-0.1.6-py3-none-any.whl |
|---|---|
| Size | 16.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8019e38697df1f39918ba817efdb5cea52cf5568284e7a1f4074e4f4b5269ef8
|
|
BLAKE2b-256 checksum How to use checksums |
68e27d0e8042fece13a3e55cbc0e2e99f0656f699a45fd7740c58171ae95bb3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Security for dobyemail 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.