Skip to main content

Email reply body generator for HTML and text in Python

Project description

replyowl

Email reply body generator for HTML and text in Python

License PyPI Python CI Coverage Renovate GitHub stars

replyowl

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

replyowl-0.2.1.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

replyowl-0.2.1-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file replyowl-0.2.1.tar.gz.

File metadata

  • Download URL: replyowl-0.2.1.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for replyowl-0.2.1.tar.gz
Algorithm Hash digest
SHA256 31f931b560f1a751467209181d12c8679e38b4daa2462001a24e792e9cbd22e0
MD5 ebcdd132fc1701acfe106aa550ce25bd
BLAKE2b-256 27429b3a10927936f9f8c72d83e512b68923eb8b63b7b3ab5f3ef2ebd19b0c86

See more details on using hashes here.

Provenance

The following attestation bundles were made for replyowl-0.2.1.tar.gz:

Publisher: release.yaml on smkent/replyowl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file replyowl-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: replyowl-0.2.1-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

Hashes for replyowl-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d576b8009dc19cb7ebcc4b4ab25360e8909cb80ca6b52d3cd3b5da332472ea5e
MD5 9270cdb6df8895846c6f312517c47d71
BLAKE2b-256 05a487c186c84da3c01714c7099c3e3af19284dbfd06ee204affb18485c83994

See more details on using hashes here.

Provenance

The following attestation bundles were made for replyowl-0.2.1-py3-none-any.whl:

Publisher: release.yaml on smkent/replyowl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page