Python Simple Email Sender
A lightweight Python library for sending emails with attachments via SMTP.
Features
- Send emails using SMTP protocol
- Support for SSL encryption
- Add attachments to emails
- Environment variable-based configuration
- Simple logging integration
Installation
pip install python-simple-email-sender
Usage
Basic Setup
First, set up your email credentials as environment variables:
export EMAIL_ADDRESS="your.email@gmail.com"
export EMAIL_PASSWORD="your-app-password-or-email-password"
Note: For Gmail accounts, you may need to use an App Password instead of your regular password, especially if you have 2-factor authentication enabled. https://myaccount.google.com/apppasswords
Simple Example
from python_simple_email_sender import EmailSender
# Create an instance with default settings (Gmail SMTP)
sender = EmailSender()
# Send a simple email
sender.send_email(
to_email=["recipient@example.com"],
subject="Hello from Python",
message="This is a test email sent using Python Simple Email Sender."
)
Custom SMTP Server
# For a different email provider
sender = EmailSender(
server_name="smtp.yourprovider.com",
server_port=587 # Use the appropriate port for your provider
)
Sending with Attachments
sender.send_email(
to_email=["recipient@example.com", "another@example.com"],
subject="Report Attached",
message="Please find the attached report.",
attachment_file="path/to/your/file.pdf"
)
Adding Multiple Attachments
sender = EmailSender()
# Create the email
sender.msg = MIMEMultipart()
sender.msg['From'] = sender.email_address
sender.msg['To'] = 'recipient@example.com'
sender.msg['Subject'] = 'Multiple Attachments'
# Add message body
text = MIMEText("Here are the files you requested.")
sender.msg.attach(text)
# Add multiple attachments
sender.add_attachment("document.pdf", subtype="pdf")
sender.add_attachment("data.csv", subtype="csv")
sender.add_attachment("image.png", subtype="png")
# Send the email
with smtplib.SMTP_SSL(sender.server_name, sender.server_port) as smtp_server:
smtp_server.login(sender.email_address, sender.email_password)
smtp_server.sendmail(
from_addr=sender.email_address,
to_addrs=['recipient@example.com'],
msg=sender.msg.as_string()
)
🤝 Contributing
If you have a helpful tool, pattern, or improvement to suggest:
Fork the repo
Create a new branch
Submit a pull request
I welcome additions that promote clean, productive, and maintainable development.
🙏 Thanks
Thanks for exploring this repository!
Happy coding!
Metadata
Release files for python-simple-email-sender 1.1.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 | Actions |
|---|---|---|---|---|
| python_simple_email_sender-1.1.0.tar.gz | 4.5 kB | Without provenance | Details for python_simple_email_sender-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_simple_email_sender-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for python_simple_email_sender-1.1.0-py3-none-any.whl |
Total release size: 9.8 kB
Release files / python_simple_email_sender-1.1.0.tar.gz
| Download URL | python_simple_email_sender-1.1.0.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bf1676076b374e2a560c4e6905027c9958bf652f626d0da789d50c166f047a91
|
|
BLAKE2b-256 checksum How to use checksums |
0aeac5da665fd2ea79183da499dbd904fee34a2a95d476c0fdd3beb009bda228
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / python_simple_email_sender-1.1.0-py3-none-any.whl
| Download URL | python_simple_email_sender-1.1.0-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c8d2e6ad68a06d1f7d5218244f30a0d8a025c3a54514384a840d86b4b7448074
|
|
BLAKE2b-256 checksum How to use checksums |
8993a77edd971ceaba138a5600d2dfaaa430873a6dab7e270af89b58b6f7d163
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for python-simple-email-sender 1.1.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.