Metadata-Version: 2.4
Name: python-simple-email-sender
Version: 1.0.7
Summary: python-simple-email-sender
Author: Avi Zaguri
License: MIT
Project-URL: Homepage, https://github.com/aviz92/python-simple-email-sender
Project-URL: Repository, https://github.com/aviz92/python-simple-email-sender
Project-URL: Issues, https://github.com/aviz92/python-simple-email-sender/issues
Keywords: development,email,smtp,sender,simple
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3.11
Classifier: Operating System :: OS Independent
Classifier: Topic :: System :: Logging
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: custom-python-logger>=2.0.10
Requires-Dist: pre-commit>=4.5.0
Requires-Dist: python-dotenv>=1.2.1
Requires-Dist: setuptools>=80.9.0
Requires-Dist: wheel>=0.45.1
Dynamic: license-file

# 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
```bash
pip install python-simple-email-sender
```

---

## Usage

### Basic Setup
First, set up your email credentials as environment variables:
```bash
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
```python
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
```python
# 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
```python
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
```python
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 <br>
Create a new branch <br>
Submit a pull request <br>
I welcome additions that promote clean, productive, and maintainable development. <br>

---

## 🙏 Thanks
Thanks for exploring this repository! <br>
Happy coding! <br>
