Email reply body generator for HTML and text in Python
Project description
replyowl
Email reply body generator for HTML and text in Python
replyowl creates email bodies with quoted messages. Provide the original message and your reply message, and replyowl will combine them into a new message. The returned content can be used as the text and/or HTML body content of a new email. HTML-to-text conversion is performed with html2text.
Installation
pip install replyowl
Usage
from replyowl import ReplyOwl
owl = ReplyOwl()
text, html = owl.compose_reply(
content="<i>New</i> reply <b>content</b>",
quote_attribution="You wrote:",
quote_text="Original message text",
quote_html="<b>Original</b> message text",
)
print(text)
# _New_ reply **content**
#
# ----
#
# You wrote:
#
# > Original message text
print(html) # (output formatted for readability)
# <!DOCTYPE html>
# <html>
# <head>
# <title></title>
# </head>
# <body>
# <i>New</i> reply <b>content</b>
# <div>You wrote:<br />
# </div>
# <blockquote style="margin-left: 0.8ex; padding-left: 2ex;
# border-left: 2px solid #aaa; border-radius: 8px;" type="cite">
# <b>Original</b> message text
# </blockquote>
# </body>
# </html>
Links in HTML are preserved when creating plain text email bodies:
from replyowl import ReplyOwl
owl = ReplyOwl()
text, html = owl.compose_reply(
content=(
'Check <a href="https://example.com/">this</a> out<br />'
'Or this: <a href="https://example.net/">https://example.net/</a>'
),
quote_attribution="You wrote:",
quote_text="Send me a URL",
quote_html="Send me a <i>URL</i>",
)
print(text)
# Check this (https://example.com/) out
# Or this: https://example.net/
#
# ----
#
# You wrote:
#
# > Send me a URL
If the quoted HTML content contains a <body> tag, that is preserved:
from replyowl import ReplyOwl
owl = ReplyOwl()
text, html = owl.compose_reply(
content="Hello there",
quote_attribution="You wrote:",
quote_text="Hi",
quote_html='<html><body class="sender_body"><b>Hi</b></body></html>',
)
print(html) # (output formatted for readability)
# <html>
# <body class="sender_body">
# Hello there
# <div>
# You wrote:<br/>
# </div>
# <blockquote style="margin-left: 0.8ex; padding-left: 2ex;
# border-left: 2px solid #aaa; border-radius: 8px;" type="cite">
# <b>Hi</b>
# </blockquote>
# </body>
# </html>
A custom value can be provided for the <blockquote>'s style tag:
from replyowl import ReplyOwl
owl = ReplyOwl(blockquote_style="font-weight: bold;")
text, html = owl.compose_reply(
text, html = owl.compose_reply(
content="Your quote is in bold",
quote_attribution="You wrote:",
quote_text="I'm going to be in bold when you reply",
quote_html="I'm going to be in bold when you reply",
)
)
print(html) # (output formatted for readability)
# <html>
# <body class="sender_body">
# Your quote is in bold
# <div>
# You wrote:<br/>
# </div>
# <blockquote style="font-weight: bold;" type="cite"
# I'm going to be in bold when you reply
# </blockquote>
# </body>
# </html>
Project template
This project is generated and maintained with copier-python.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file replyowl-0.2.2.tar.gz.
File metadata
- Download URL: replyowl-0.2.2.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d32d703352d8e7c250b9d133d52b51c4ccf4c4c9629c60e435442fdbc6a3f926
|
|
| MD5 |
6b48f05ef1be6ed307ecebeb3f5d177d
|
|
| BLAKE2b-256 |
c43718c2e261797c923be107adbcc33f2002466a32e93bedef64f17daaa32f6e
|
Provenance
The following attestation bundles were made for replyowl-0.2.2.tar.gz:
Publisher:
release.yaml on smkent/replyowl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
replyowl-0.2.2.tar.gz -
Subject digest:
d32d703352d8e7c250b9d133d52b51c4ccf4c4c9629c60e435442fdbc6a3f926 - Sigstore transparency entry: 1399433323
- Sigstore integration time:
-
Permalink:
smkent/replyowl@c24e17076cbc6fdbbdcf89dcc5a55b7c5798ed1d -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/smkent
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@c24e17076cbc6fdbbdcf89dcc5a55b7c5798ed1d -
Trigger Event:
push
-
Statement type:
File details
Details for the file replyowl-0.2.2-py3-none-any.whl.
File metadata
- Download URL: replyowl-0.2.2-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c5dcc55608798c45a44ce994da4db8cccd6ef526328670ab90c724621831c93
|
|
| MD5 |
646bb86fd0787be6fdad1c9e5ed28aa9
|
|
| BLAKE2b-256 |
a93db6d33b3f8ada7cbaf6bc7b3ddf2d6503299dfe7156b9607c921d9f3ad255
|
Provenance
The following attestation bundles were made for replyowl-0.2.2-py3-none-any.whl:
Publisher:
release.yaml on smkent/replyowl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
replyowl-0.2.2-py3-none-any.whl -
Subject digest:
9c5dcc55608798c45a44ce994da4db8cccd6ef526328670ab90c724621831c93 - Sigstore transparency entry: 1399433353
- Sigstore integration time:
-
Permalink:
smkent/replyowl@c24e17076cbc6fdbbdcf89dcc5a55b7c5798ed1d -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/smkent
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@c24e17076cbc6fdbbdcf89dcc5a55b7c5798ed1d -
Trigger Event:
push
-
Statement type: