Email reply body generator for HTML and text
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
replyowl is available on PyPI:
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>
Development
Poetry installation
Via pipx
:
pip install pipx
pipx install poetry
pipx inject poetry poetry-dynamic-versioning poetry-pre-commit-plugin
Via pip
:
pip install poetry
poetry self add poetry-dynamic-versioning poetry-pre-commit-plugin
Development tasks
- Setup:
poetry install
- Run static checks:
poetry run poe lint
orpoetry run pre-commit run --all-files
- Run static checks and tests:
poetry run poe test
Created from smkent/cookie-python using cookiecutter
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
File details
Details for the file replyowl-0.1.16.tar.gz
.
File metadata
- Download URL: replyowl-0.1.16.tar.gz
- Upload date:
- Size: 16.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87629d7381f749065678e6137f5a2a32c616bd38bb54f2671082440e9d434f35 |
|
MD5 | 6cd0635cb3337b0ade247fc69bf2c035 |
|
BLAKE2b-256 | dc2d2a9bf0a5140560c8745a9bebd974efdda33664b7471e9a985025395e9f9f |
File details
Details for the file replyowl-0.1.16-py3-none-any.whl
.
File metadata
- Download URL: replyowl-0.1.16-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23875d27167be877c45683da7fe130003fc614f59e45f6049715f6a5c9d84023 |
|
MD5 | 796921a96499520871afd936634b70e4 |
|
BLAKE2b-256 | d98bd974066f8ecd6d205dceebdfc9a2e5311f190dfc4598bfdd90e458dc0cce |