Metadata-Version: 2.4
Name: exmailer
Version: 1.0.0
Summary: Send emails via Microsoft Exchange Server with HTML template support
Project-URL: Homepage, https://github.com/aerosadegh/exmailer
Project-URL: Repository, https://github.com/aerosadegh/exmailer
Project-URL: Documentation, https://exmailer.readthedocs.io
Project-URL: Bug Tracker, https://github.com/aerosadegh/exmailer/issues
Author-email: Sadegh Yazdani <sadegh.yazdani@example.com>
License: GPL-3.0-or-later
License-File: LICENSE
Keywords: email,exchange,microsoft,notification,outlook,persian,rtl,smtp
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Communications :: Email
Classifier: Topic :: Office/Business
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Requires-Dist: exchangelib>=5.0.0
Requires-Dist: urllib3>=2.0.0
Provides-Extra: dev
Requires-Dist: black>=23.0.0; extra == 'dev'
Requires-Dist: isort>=7.0.0; extra == 'dev'
Requires-Dist: mypy>=1.0.0; extra == 'dev'
Requires-Dist: pre-commit>=3.0.0; extra == 'dev'
Requires-Dist: pytest-console-scripts>=1.4.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest-mock>=3.10.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs-autorefs>=1.0; extra == 'docs'
Requires-Dist: mkdocs-gen-files>=0.5; extra == 'docs'
Requires-Dist: mkdocs-literate-nav>=0.6; extra == 'docs'
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
Requires-Dist: mkdocs-section-index>=0.3; extra == 'docs'
Requires-Dist: mkdocs>=1.6; extra == 'docs'
Requires-Dist: mkdocstrings[python]>=0.25; extra == 'docs'
Requires-Dist: pymdown-extensions>=10.0; extra == 'docs'
Provides-Extra: test
Requires-Dist: pytest-console-scripts>=1.4.0; extra == 'test'
Requires-Dist: pytest-cov>=4.0.0; extra == 'test'
Requires-Dist: pytest-mock>=3.10.0; extra == 'test'
Requires-Dist: pytest>=7.0.0; extra == 'test'
Provides-Extra: yaml
Requires-Dist: pyyaml>=6.0; extra == 'yaml'
Description-Content-Type: text/markdown

# Ex(change E)mailer 🐍

<div align="center">
  <p><strong>Enterprise-Grade Microsoft Exchange Email Client with HTML Template Support</strong></p>
  <p>
    <a href="https://pypi.org/project/exmailer/"><img src="https://img.shields.io/pypi/v/exmailer.svg" alt="PyPI"></a>
    <a href="https://pypi.org/project/exmailer/"><img src="https://img.shields.io/pypi/pyversions/exmailer.svg" alt="Python Versions"></a>
    <a href="https://github.com/aerosadegh/exmailer/actions"><img src="https://github.com/aerosadegh/exmailer/workflows/Publish%20to%20PyPI/badge.svg" alt="Build Status"></a>
    <a href="https://github.com/aerosadegh/exmailer/blob/main/LICENSE"><img src="https://img.shields.io/github/license/aerosadegh/exmailer.svg" alt="License"></a>
  </p>
</div>

**ExMailer** is a robust Python library designed for robust interaction with Microsoft Exchange Servers (EWS). It solves the complexity of NTLM authentication and provides a flexible, HTML templating engine out of the box.

## Features

- **Microsoft Exchange Integration**: Seamless connection to Exchange servers using NTLM authentication
- **Rich Email Formatting**: Professional HTML email templates with customizable variables
- **Attachment Support**: Handle multiple file attachments with automatic MIME type detection
- **Flexible Configuration**: Support for environment variables, JSON config files, or programmatic setup
- **CLI Interface**: Command-line tool for quick email sending
- **Comprehensive Error Handling**: Custom exceptions for different failure scenarios
- **Secure SSL/TLS**: Proper certificate verification and secure connections
- **Logging Support**: Verbose mode for debugging and troubleshooting

## Installation
Requires Python 3.11+

```bash
pip install exmailer
```


## Quick Start

### Using Python API

```python
from exmailer import ExchangeEmailer

with ExchangeEmailer() as emailer:
    emailer.send_email(
        subject="گزارش هفتگی",
        body="لطفاً گزارش پیوست شده را بررسی نمایید.",
        recipients=["manager@company.com"],
        template=TemplateType.PERSIAN,  # Uses built-in RTL template
        attachments="./report.pdf",
    )

    # Send a standard English/LTR email
    emailer.send_email(
        subject="Weekly Report",
        body="Please find attached.",
        recipients=["colleague@company.com"],
        template=TemplateType.DEFAULT
        attachments="./report.pdf",
    )
```

#### Custom Templates
You can register custom HTML layouts for newsletters or alerts:
```python
from exmailer import ExchangeEmailer, register_custom_template

html_layout = """
<div style="border: 1px solid #ccc; padding: 20px;">
    <h1 style="color: navy;">Company Alert</h1>
    {body}
    <hr>
    <small>Confidential</small>
</div>
"""

register_custom_template("alert", html_layout)

with ExchangeEmailer() as emailer:
    emailer.send_email(
        subject="Server Down",
        body="<p>The main database is unreachable.</p>",
        recipients=["devops@company.com"],
        template="alert"  # Use the registered name
    )
```

### Using CLI (Under Construction)

```bash
python -m exchange_emailer \
    --subject "Weekly Report" \
    --body "Report content here" \
    --to recipient@company.com \
    --attachments ./report.pdf
```

## Configuration
ExMailer looks for `exmailer.json` or `exmailer.yaml` in your current directory or `~/.config/exmailer/`.

Set environment variables `.env`:

```bash
EXCHANGE_DOMAIN="CORP"
EXCHANGE_USER="jdoe"
EXCHANGE_PASS="secret_password"
EXCHANGE_SERVER="mail.corp.com"
EXCHANGE_EMAIL_DOMAIN="corp.com"
EXCHANGE_AUTH_TYPE="NTLM" # or BASIC
```

Or use a JSON config file `exmailer.json`:

```json
{
  "domain": "CORP",
  "username": "jdoe",
  "password": "secret_password",
  "server": "mail.corp.com",
  "email_domain": "corp.com",
  "auth_type": "NTLM",
  "save_copy": true
}
```

## Requirements

- Python 3.10+
- Microsoft Exchange Server access
- Valid domain credentials

## Author

Sadegh Yazdani

## License

GNU General Public License v3 (GPLv3)

