A collection of tools
Project description
email_tools
Tools and utilities related to email
send_email
Send an email.
to: str or list; specify email addresses for the To linecc: str or list; specify email addresses for the Cc linebcc: str or list; specify email addresses for the Bcc linesubject: str; specify the email subject line. Can be altered with string_toolsbody_txt: str; specify the simple text body for the email- If body_txt is specified and
body_htmlis NOT specified, a simple (MIMEText) email will be sent
- If body_txt is specified and
body_html: str; specify the body for the email, incluing complex layout and formatting- If body_html is specified, a complex (MIMEMultipart) email will be sent. A simplified body (
body_txt) can ALSO be specified and will be encoded along with the complex email body
- If body_html is specified, a complex (MIMEMultipart) email will be sent. A simplified body (
email_account: str; originating email accountfrom_description: str or None; text description of the originating email account. Example would be 'Notifications'. Can be altered with string_toolsemail_password: str; password for sending email accountsmtp_domain: str; smtp domain for sending email accountsmtp_port: int; port for smtp domain sending email
from hotbrush.email_tools import send_email
# Simple text
body_txt = f"Head's up, your {device} battery is at {pct}!!"
# HTML body
body_html = "<h1>Head's up, your {device} battery is at <b>{pct}</b>!!</h1>"
send_email(
email_account='sendaccount@gmail.com',
from_description='Automated alerts',
email_password='abc123jkjk',
to='my_account@gmail.com',
subject=f'Your {device} battery is at {pct}',
body_txt=body_txt,
body_html=body_html,
)
# Make it a little more fun with `string_tools`
from hotbrush.string_tools import to_preheader_text_html, to_styled_unicode
# Custom 'preview' text, different from message body
preheader = to_preheader_text_html('One simple trick for understanding devices')
# Change from_description and subject line 'font' by altering characters used
from_description = to_styled_unicode('Automated alerts', 'math bold script')
subject = '⚠️🚨🥵 ' + to_styled_unicode(f'Your {device} battery is at {pct}')
send_email(
email_account='sendaccount@gmail.com',
from_description=from_description,
email_password='abc123jkjk',
to='my_account@gmail.com',
subject=subject,
body_txt=body_txt,
body_html=body_html,
)
string_tools
Tools and utilities related to manipulating strings
to_preheader_text_html
Create an HTML string for use in an email body to customize the email preview text when viewing an email in an inbox. Ref this preview text article.
preheader_text: str; string (including unicode or emoji) to be added to the HTMLtag_type: str; 'span' (default) or 'div'. Adapted from a MailChimp methodtarget_text_len: int; length of text to fill- Some email previews will fill in body text to the preview if the preheader text does not completely fill the space
space_filler: str; characters to fill difference between actual preheader text and the target_text_len.
Review the send_email documentation for more detail.
from hotbrush.string_tools import to_preheader_text_html
preheader_text = 'Oh man you really have to read this'
preheader = to_preheader_text_html(preheader_text)
# Send an email
from hotbrush.email_tools import send_email
...
body_html = f'{preheader}<h1><b>OTHER THINGS</b></h1>'
...
# See the email_tools#send_email documentation for more detail
to_styled_unicode
Replace normal ASCII characters with styled Unicode characters. Direct use-case is for email sender and subject line modification. If no transformed character is found, the original character is returned.
characters: str or list; convert plain text (letters, sometimes numbers, sometimes punctuation) to obscure characters from Unicode. Direct use-case is for replacing characters. Directly from Unicode Text Convertertransform: str; name of Unicode transform to convert characters to 'print' to display the name and available characters for each transform
from hotbrush.string_tools import to_styled_unicode
custom_subject = to_styled_unicode('🤔🤔 Hey HEY', 'math bold italic')
custom_subject += ', '
custom_subject += to_styled_unicode('check out my sweet ', 'math bold')
custom_subject += to_styled_unicode('subject line')
print(custom_subject)
🤔🤔 𝑯𝒆𝒚 𝑯𝑬𝒀, 𝐜𝐡𝐞𝐜𝐤 𝐨𝐮𝐭 𝐦𝐲 𝐬𝐰𝐞𝐞𝐭 🆂🆄🅱🅹🅴🅲🆃 🅻🅸🅽🅴
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 hotbrush-0.0.1.tar.gz.
File metadata
- Download URL: hotbrush-0.0.1.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c7e774d2cf2b07887f21eb06014e80cc7f296390a44d0adfe9eb1850dc3f6d7
|
|
| MD5 |
38b2a2a306a2429d32409df0afa9f0cd
|
|
| BLAKE2b-256 |
823ebf50d1f29c33afd57ea51d35f11695b411bfe4763a98b9f1e805ec8d762e
|
File details
Details for the file hotbrush-0.0.1-py3-none-any.whl.
File metadata
- Download URL: hotbrush-0.0.1-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
213977cb4dd1d5da08bd0cf67c6b50cbc753c964cc6e090a078dd623736e698e
|
|
| MD5 |
2c7c46bf9fb4544a1d30f317b88b2b61
|
|
| BLAKE2b-256 |
217d1d8e931eb43e2c527e0961674bb94d7dce20d057f008799d9c9206f407e4
|