Skip to content

Commit a940210

Browse files
committed
README update
1 parent 5549b5b commit a940210

2 files changed

Lines changed: 164 additions & 64 deletions

File tree

README.rst

Lines changed: 156 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,174 @@
11
python-emails
2-
~~~~~~~~~~~~~
2+
=============
33

4-
Modern python library for email.
4+
.. |pypi| image:: https://img.shields.io/pypi/v/emails.svg
5+
:target: https://pypi.org/project/emails/
6+
:alt: PyPI version
57

6-
Build message:
8+
.. |python| image:: https://img.shields.io/pypi/pyversions/emails.svg
9+
:target: https://pypi.org/project/emails/
10+
:alt: Python versions
711

8-
.. code-block:: python
12+
.. |tests| image:: https://github.com/lavr/python-emails/workflows/Tests/badge.svg?branch=master
13+
:target: https://github.com/lavr/python-emails/actions?query=workflow%3ATests
14+
:alt: Test status
15+
16+
.. |docs| image:: https://readthedocs.org/projects/python-emails/badge/?version=latest
17+
:target: https://python-emails.readthedocs.io/
18+
:alt: Documentation status
19+
20+
.. |license| image:: https://img.shields.io/pypi/l/emails.svg
21+
:target: https://github.com/lavr/python-emails/blob/master/LICENSE
22+
:alt: License
23+
24+
|pypi| |python| |tests| |docs| |license|
25+
26+
Build, transform, and send emails in Python with a high-level API.
927

10-
>>> import emails
11-
>>> message = emails.html(html="<p>Hi!<br>Here is your receipt...",
12-
subject="Your receipt No. 567098123",
13-
mail_from=('Some Store', 'store@somestore.com'))
14-
>>> message.attach(data=open('bill.pdf', 'rb'), filename='bill.pdf')
28+
``python-emails`` helps you compose HTML and plain-text messages, attach files,
29+
embed inline images, render templates, apply HTML transformations, sign with
30+
DKIM, and send through SMTP without hand-building MIME trees.
1531

16-
send message and get response from smtp server:
32+
33+
Why python-emails
34+
-----------------
35+
36+
- A concise API over ``email`` and ``smtplib``
37+
- HTML and plain-text messages in one object
38+
- File attachments and inline images
39+
- CSS inlining, image embedding, and HTML cleanup
40+
- Jinja2, Mako, and string template support
41+
- DKIM signing
42+
- Loaders for URLs, HTML files, directories, ZIP archives, and RFC 822 messages
43+
- SMTP sending with SSL/TLS support
44+
- Async sending via ``aiosmtplib``
45+
46+
47+
Quick Example
48+
-------------
1749

1850
.. code-block:: python
1951
20-
>>> r = message.send(to='s@lavr.me', smtp={'host': 'aspmx.l.google.com', 'timeout': 5})
21-
>>> assert r.status_code == 250
52+
import emails
2253
23-
and more:
54+
message = emails.html(
55+
subject="Your receipt",
56+
html="<p>Hello!</p><p>Your payment was received.</p>",
57+
mail_from=("Billing", "billing@example.com"),
58+
)
59+
message.attach(filename="receipt.pdf", data=open("receipt.pdf", "rb"))
2460
25-
* DKIM signature
26-
* Render body from template
27-
* Flask extension and Django integration
28-
* HTML transformation with CSS inlining (``pip install emails[html]``)
29-
* Load message from url or from file
61+
response = message.send(
62+
to="customer@example.com",
63+
smtp={
64+
"host": "smtp.example.com",
65+
"port": 587,
66+
"tls": True,
67+
"user": "billing@example.com",
68+
"password": "app-password",
69+
},
70+
)
71+
assert response.status_code == 250
3072
31-
|
3273
33-
Documentation: `python-emails.readthedocs.io <https://python-emails.readthedocs.io/>`_
74+
Installation
75+
------------
3476

35-
Flask extension: `flask-emails <https://github.com/lavr/flask-emails>`_
77+
Install the lightweight core:
3678

37-
|
38-
|
79+
.. code-block:: bash
80+
81+
pip install emails
82+
83+
Install HTML transformation features such as CSS inlining, image embedding,
84+
and loading from URLs or files:
85+
86+
.. code-block:: bash
87+
88+
pip install "emails[html]"
89+
90+
Install Jinja2 template support for the ``JinjaTemplate`` class:
91+
92+
.. code-block:: bash
93+
94+
pip install "emails[jinja]"
95+
96+
Install async SMTP sending support for ``send_async()``:
97+
98+
.. code-block:: bash
99+
100+
pip install "emails[async]"
101+
102+
103+
Common Tasks
104+
------------
105+
106+
- Build and send your first message:
107+
`Quickstart <https://python-emails.readthedocs.io/en/latest/quickstart.html>`_
108+
- Configure installation extras:
109+
`Install guide <https://python-emails.readthedocs.io/en/latest/install.html>`_
110+
- Inline CSS, embed images, and customize HTML processing:
111+
`Advanced Usage <https://python-emails.readthedocs.io/en/latest/advanced.html>`_
112+
- Learn the full public API:
113+
`API Reference <https://python-emails.readthedocs.io/en/latest/api.html>`_
114+
- Troubleshoot common scenarios:
115+
`FAQ <https://python-emails.readthedocs.io/en/latest/faq.html>`_
116+
- Explore alternatives and related projects:
117+
`Links <https://python-emails.readthedocs.io/en/latest/links.html>`_
118+
119+
120+
What You Get
121+
------------
122+
123+
- Message composition for HTML, plain text, headers, CC/BCC, and Reply-To
124+
- Attachments, inline images, and MIME generation
125+
- Template rendering in ``html``, ``text``, and ``subject``
126+
- HTML transformations through ``message.transform()``
127+
- SMTP delivery through config dicts or reusable backend objects
128+
- Django integration via ``DjangoMessage``
129+
- Flask integration via `flask-emails <https://github.com/lavr/flask-emails>`_
130+
131+
132+
When To Use It
133+
--------------
134+
135+
Use ``python-emails`` when you need more than a minimal plain-text SMTP call:
136+
HTML emails, attachments, inline images, template rendering, DKIM, message
137+
loading from external sources, or a cleaner API than hand-written
138+
``email.mime`` code.
139+
140+
If you only need to send a very small plain-text message and want zero
141+
dependencies, the standard library may be enough.
142+
143+
144+
Documentation
145+
-------------
146+
147+
- `Documentation home <https://python-emails.readthedocs.io/>`_
148+
- `Quickstart <https://python-emails.readthedocs.io/en/latest/quickstart.html>`_
149+
- `Advanced Usage <https://python-emails.readthedocs.io/en/latest/advanced.html>`_
150+
- `API Reference <https://python-emails.readthedocs.io/en/latest/api.html>`_
151+
- `FAQ <https://python-emails.readthedocs.io/en/latest/faq.html>`_
152+
153+
154+
Project Status
155+
--------------
156+
157+
``python-emails`` is production/stable software and currently supports
158+
Python 3.10 through 3.14.
159+
160+
161+
Contributing
162+
------------
163+
164+
Issues and pull requests are welcome.
165+
166+
- `Report a bug or request a feature <https://github.com/lavr/python-emails/issues>`_
167+
- `Source code on GitHub <https://github.com/lavr/python-emails>`_
168+
- `How to Help <https://python-emails.readthedocs.io/en/latest/howtohelp.html>`_
39169

40-
.. image:: https://github.com/lavr/python-emails/workflows/Tests/badge.svg?branch=master
41-
:target: https://github.com/lavr/python-emails/actions?query=workflow%3ATests
42170

43-
.. image:: https://img.shields.io/pypi/v/emails.svg
44-
:target: https://pypi.python.org/pypi/emails
171+
License
172+
-------
45173

174+
Apache 2.0. See `LICENSE <https://github.com/lavr/python-emails/blob/master/LICENSE>`_.

setup.py

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,4 @@
1-
"""
2-
3-
python-emails
4-
~~~~~~~~~~~~~
5-
6-
Modern python library for email.
7-
8-
Build message:
9-
10-
>>> import emails
11-
>>> message = emails.html(html="<p>Hi!<br>Here is your receipt...",
12-
subject="Your receipt No. 567098123",
13-
mail_from=('Some Store', 'store@somestore.com'))
14-
>>> message.attach(data=open('bill.pdf'), filename='bill.pdf')
15-
16-
send message and get response from smtp server:
17-
18-
>>> r = message.send(to='s@lavr.me', smtp={'host': 'aspmx.l.google.com', 'timeout': 5})
19-
>>> assert r.status_code == 250
20-
21-
and more:
22-
23-
* DKIM signature
24-
* Render body from template
25-
* Flask extension and Django integration
26-
* Message body transformation methods
27-
* Load message from url or from file
28-
29-
30-
Links
31-
`````
32-
33-
* `documentation <https://python-emails.readthedocs.io/>`_
34-
* `source code <https://github.com/lavr/python-emails>`_
35-
36-
"""
1+
"""Setup configuration for python-emails."""
372

383
import codecs
394
import os
@@ -104,11 +69,17 @@ def find_version(*file_paths):
10469
raise RuntimeError("Unable to find version string.")
10570

10671

72+
def read_file(filename):
73+
file_path = os.path.join(os.path.dirname(__file__), filename)
74+
with codecs.open(file_path, encoding='utf-8') as fh:
75+
return fh.read()
76+
77+
10778
settings.update(
10879
name='emails',
10980
version=find_version('emails/__init__.py'),
11081
description='Modern python library for emails.',
111-
long_description=__doc__,
82+
long_description=read_file('README.rst'),
11283
long_description_content_type='text/x-rst',
11384
author='Sergey Lavrinenko',
11485
author_email='s@lavr.me',

0 commit comments

Comments
 (0)