Simple sending of smtp emails using env variables
Project description
envsmtp
Simple sending of smtp emails using environment variables
Install
pip install --upgrade envsmtp
Environment Variables
You must set SMTP_USER and SMTP_PASS in your environment with your user and password!
See additional optional settings in example.env
Usage
This package will by default use STARTTLS settings for smtp.gmail.com on port 587. If you wish to change these settings, you can set your own environment variables for SMTP_HOST and SMTP_PORT
Once installed, here's a simple example of how to use this package:
from envsmtp import EmailMessage
msg = EmailMessage(
sender="sender@example.com",
recipients="recipient@example.com",
subject="envsmtp test",
body="This is just a test message",
)
msg.smtp_send()
To send with attachments:
from envsmtp import EmailMessage, EmailAttachment
attachments = [
EmailAttachment(content='/path/to/file.txt'),
EmailAttachment(content=b'randombytes', filename='bytes_test.txt'),
EmailAttachment(content='/path/to/another.txt', filename='this_name_is_different_.txt')
]
msg = EmailMessage(
sender="sender@example.com",
recipients="recipient@example.com",
subject="envsmtp test",
body="This is just a test message",
attachments=attachments,
)
msg.smtp_send()
Requirements
Supports Python 3.10 and above (currently tested in CI on 3.10-3.13). Project dependencies are defined in pyproject.toml.
Testing
Install project + dev dependencies:
uv sync --locked --group dev
Run all tests (default + integration) with coverage using a single command:
just test
Integration tests require SMTP_USER, SMTP_PASS, and SMTP_TEST. If missing, integration tests are skipped.
Contributing
For bugs / feature requests please submit issues
If you would like to contribute to this project, you are welcome to submit a pull request
Warranty / Liability / Official support
This project is being developed independently, we provide the package "as-is" without any implied warranty or liability, usage is your own responsibility
Additional info
Just because I like badges
Project details
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 envsmtp-0.3.0.tar.gz.
File metadata
- Download URL: envsmtp-0.3.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
358df46a0170a5ea5f1273f897a14f0d1d8038e0465692c9d0e3432cbd0068a3
|
|
| MD5 |
5a477eb334fb55d3189ef4375536db64
|
|
| BLAKE2b-256 |
d8b3b6340777b035dab3ed68a079b7f44f1a83a240f68cbadf53737c111c8de2
|
File details
Details for the file envsmtp-0.3.0-py3-none-any.whl.
File metadata
- Download URL: envsmtp-0.3.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0b1f2d5bb586e526cfce9360529462f407b0be0779afcabb17490d43202ba93
|
|
| MD5 |
85d37fd42cf72180e1789cac9fd06f9a
|
|
| BLAKE2b-256 |
6496af5f68d24e6cb01a65893793f27e74867d2e79a284853367877b8b14e011
|