Metadata-Version: 2.4
Name: rick-mailer
Version: 1.1.2
Summary: Simple library to send emails
Home-page: https://git.oddbit.org/OddBit/rick-mailer
Author: João Pinheiro
License: BSD-3-Clause
Project-URL: Documentation, https://docs.oddbit.org/rick-mailer/
Project-URL: Source, https://git.oddbit.org/OddBit/rick-mailer
Classifier: Environment :: Web Environment
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: rick>=0.8.3
Dynamic: license-file

# Rick-mailer - Library to send emails 

[![Tests](https://github.com/oddbit-project/rick-mailer/workflows/Tests/badge.svg?branch=master)](https://github.com/oddbit-project/rick-mailer/actions)
[![pypi](https://img.shields.io/pypi/v/rick-mailer.svg)](https://pypi.org/project/rick-mailer/)
[![license](https://img.shields.io/pypi/l/rick-mailer.svg)](https://github.com/oddbit-project/rick-mailer/blob/master/LICENSE)


rick_mailer is a standalone version of Django's email library implementation, with minor changes.

## Installation

```shell
$ pip3 install rick-mailer
```

## Usage

```python
from rick_mailer import SMTPFactory, Mailer

cfg = {
    'smtp_host': '127.0.0.1',
    'smtp_port': 25,
    'smtp_username': 'relay@local',
    'smtp_password': 'securePassword',
    'smtp_use_tls': False,
    'smtp_use_ssl': False,
}
conn = SMTPFactory(cfg)

mailer = Mailer(conn)
mailer.send_mail('some subject', 'message contents', 'noreply@localhost', ['user1@domain.tld', 'user2@domain.tld'])
```

### Configuration options

`SMTPFactory(cfg)` reads the following keys from `cfg`:

| Key | Default | Description |
| --- | --- | --- |
| `smtp_host` | `'localhost'` | SMTP server hostname. |
| `smtp_port` | `25` | SMTP server port. |
| `smtp_username` | `''` | Username for authentication (empty disables login). |
| `smtp_password` | `''` | Password for authentication. |
| `smtp_use_tls` | `False` | Use STARTTLS on a plain connection. |
| `smtp_use_ssl` | `False` | Use an implicit TLS (SSL) connection. Mutually exclusive with `smtp_use_tls`. |
| `smtp_timeout` | `None` | Socket timeout in seconds. |
| `smtp_ssl_keyfile` | `None` | Path to a client-side private key (PEM). |
| `smtp_ssl_certfile` | `None` | Path to a client-side certificate (PEM); required when `smtp_ssl_keyfile` is set. |

> **Security note:** `smtp_use_tls` and `smtp_use_ssl` default to `False`. When sending credentials
> (`smtp_username`/`smtp_password`), enable one of them (`smtp_use_tls=True` for STARTTLS, or
> `smtp_use_ssl=True` for an implicit TLS connection) so the password is not transmitted in cleartext.

## Related tools

Check out [Mailpit](https://github.com/axllent/mailpit), a mail testing tool for developers.

## License
As rick_mailer is mostly Django code, it is licensed under Django license and copyright - see the included [License file](LICENSE).
