Imhotep Mail
This is a simple Python library for sending emails. It provides an easy way to configure and send emails from any Python code.
Installation
To install the imhotep_mail library, you can use pip:
pip install imhotep-mail
Usage
Recommended Method: Configure SMTP Settings Globally
The recommended way to use the library is by configuring SMTP settings globally using the set_mail_config function:
from imhotep_mail import set_mail_config
# Set global SMTP configuration
set_mail_config(
smtp_server='smtp.example.com',
smtp_port=465,
username='your-email@example.com',
password='your-password',
user_tls=True, # Optional, default is True
user_ssl=False # Optional, default is False
)
Then, send emails using the send_mail function:
from imhotep_mail import send_mail
# Sending an email
success, error = send_mail(
to_email='recipient@example.com',
subject='Hello from Imhotep Mail!',
body='This is a test email sent using the Imhotep Mail library.',
is_html=False
)
if error:
print(f"Error: {error}")
else:
print(success)
Legacy Method: Passing SMTP Configuration Directly
For backward compatibility, you can still use the send_mail function by passing SMTP configuration directly. This method is not recommended for new code:
from imhotep_mail import send_mail
# Sending an email using the legacy method
success, error = send_mail(
'smtp.example.com', 465, 'your-email@example.com', 'your-password',
to_email='recipient@example.com',
subject='Hello from Imhotep Mail!',
body='This is a test email sent using the Imhotep Mail library.',
is_html=False
)
if error:
print(f"Error: {error}")
else:
print(success)
Using Gmail with App Passwords
If you are using Gmail, you need to enable "App Passwords" to use this library. Follow these steps:
- Go to your Google Account Security Settings.
- Enable 2-Step Verification if it is not already enabled.
- Under "Signing in to Google," click on "App Passwords."
- Generate an app password for "Mail" and "Other" (e.g., "Imhotep Mail").
- Use the generated password in place of your Gmail account password in the
set_mail_configfunction.
Example:
from imhotep_mail import set_mail_config, send_mail
# Set global SMTP configuration for Gmail
set_mail_config(
smtp_server='smtp.gmail.com',
smtp_port=587,
username='your-email@gmail.com',
password='your-app-password',
user_tls=True,
user_ssl=False
)
# Send an email
success, error = send_mail(
to_email='recipient@example.com',
subject='Hello from Imhotep Mail!',
body='This is a test email sent using Gmail with App Passwords.',
is_html=False
)
if error:
print(f"Error: {error}")
else:
print(success)
Sending an Email with Attachments
Both methods support sending emails with attachments. For example, using the recommended method:
from imhotep_mail import send_mail
# Sending an email with attachments
success, error = send_mail(
to_email='recipient@example.com',
subject='Hello from Imhotep Mail!',
body='This is a test email sent using the Imhotep Mail library.',
is_html=False,
attachments=['path/to/attachment1.pdf', 'path/to/attachment2.jpg']
)
if error:
print(f"Error: {error}")
else:
print(success)
Using the CLI
The library also provides a CLI tool for sending emails. To use it, run the following command:
imhotep-mail-cli --to recipient@example.com --subject "Hello from CLI" --body "This is a test email sent using the CLI." --is-html --attachments path/to/attachment1.pdf path/to/attachment2.jpg --smtp-server smtp.gmail.com --smtp-port 587 --smtp-username your-email@gmail.com --smtp-password your-app-password --use-tls
CLI Arguments
--to: Recipient email address (required).--subject: Email subject (required).--body: Email body (required).--is-html: Send email as HTML (optional).--attachments: Paths to attachment files (optional).--smtp-server: SMTP server address (optional, overrides environment variables).--smtp-port: SMTP server port (optional, overrides environment variables).--smtp-username: SMTP username (optional, overrides environment variables).--smtp-password: SMTP password (optional, overrides environment variables).--use-tls: Use TLS for SMTP (optional).--use-ssl: Use SSL for SMTP (optional).
Contributing
Contributions are welcome! You can submit issues and pull requests to help improve the library.
License
MIT License. See LICENSE for more information.
Metadata
Release files for imhotep-mail 1.0.0
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 | |
|---|---|---|---|---|
| imhotep_mail-1.0.0.tar.gz | 5.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| imhotep_mail-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.9 kB
Release files / imhotep_mail-1.0.0.tar.gz
| Download URL | imhotep_mail-1.0.0.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4a42fda6af6c4402b9bc6ac44c2536755efc51d89937377ce15297bc55f13c3d
|
|
BLAKE2b-256 checksum How to use checksums |
41280d00c8e2edcc0b3e0c062f583b7bef7a8d3797a30b0c68d36e15995d6c95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / imhotep_mail-1.0.0-py3-none-any.whl
| Download URL | imhotep_mail-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fbaa02314fada5e44adb308fa58c1ef844cad04db648ca9a3f23e36a48edd1d8
|
|
BLAKE2b-256 checksum How to use checksums |
5c064bd9879981809e38c1b4e8e9aa95d75bc70db871f752c8b154cae34e6f4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for imhotep-mail 1.0.0
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.