html2eml
html2eml is a simple package for converting HTML text to EML format (MIME RFC 2822).
Getting started
Create simple message with to and from headers
>>> import html2eml
>>> msg = html2eml.from_html('<html><body><p>Hello world</p></body></html>', to='spam@example.com', from_='eggs@example.com', subject='Sausage')
>>> print(msg.as_string())
MIME-Version: 1.0
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: base64
To: spam@example.com
From: eggs@example.com
Subject: =?utf-8?q?Sausage?=
PGh0bWw+PGJvZHk+PHA+SGVsbG8gd29ybGQ8L3A+PC9ib2R5PjwvaHRtbD4=
html2eml allows changing charset of html message
>>> msg = html2eml.from_html('<html><body><p>Hello world</p></body></html>', charset='ISO-8859-1', to='spam@example.com')
>>> print(msg.as_string())
MIME-Version: 1.0
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
To: spam@example.com
<html><body><p>Hello world</p></body></html>
Outside of To and From fields we can also specify CC and BCC
>>> msg = html2eml.from_html('<html><body><p>Hello world</p></body></html>', to='foo@example.com', from_='bar@example.com', cc='spam@example.com', bcc='eggs@example.com')
>>> print(msg.as_string())
MIME-Version: 1.0
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: base64
To: foo@example.com
From: bar@example.com
CC: spam@example.com
BCC: eggs@example.com
PGh0bWw+PGJvZHk+PHA+SGVsbG8gd29ybGQ8L3A+PC9ib2R5PjwvaHRtbD4=
In case of multiple recipients we can pass a list in any of those fields
>>> msg = html2eml.from_html('<html><body><p>Hello world</p></body></html>', to=['foo@example.com', 'spam@example.com', 'eggs@example.com'], from_='bar@example.com')
>>> print(msg.as_string())
MIME-Version: 1.0
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: base64
To: foo@example.com, spam@example.com, eggs@example.com
From: bar@example.com
PGh0bWw+PGJvZHk+PHA+SGVsbG8gd29ybGQ8L3A+PC9ib2R5PjwvaHRtbD4
Library also supports converting plain EML messages to MIME Multipart messages
>>> msg = html2eml.from_html('<html><body><p>Hello world</p></body></html>', to=['foo@example.com', 'spam@example.com', 'eggs@example.com'], from_='bar@example.com')
>>> multipart = html2eml.convert_eml_to_multipart(msg)
>>> print(multipart.as_string())
MIME-Version: 1.0
Content-Type: multipart/mixed; charset="utf-8"; boundary="===============2813024326530809151=="
Content-Transfer-Encoding: base64
To: foo@example.com, spam@example.com, eggs@example.com
From: bar@example.com
--===============2813024326530809151==
Content-Type: text/html; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
PGh0bWw+PGJvZHk+PHA+SGVsbG8gd29ybGQ8L3A+PC9ib2R5PjwvaHRtbD4=
--===============2813024326530809151==--
Metadata
Release files for html2eml 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| html2eml-0.0.5.tar.gz | 2.7 kB | Without provenance | Details for html2eml-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| html2eml-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for html2eml-0.0.5-py3-none-any.whl |
Total release size: 6.4 kB
Release files / html2eml-0.0.5.tar.gz
| Download URL | html2eml-0.0.5.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6461b73ef844be83b402360f216e476298ba7c88d0b844bb3acd579aa8db4b84
|
|
BLAKE2b-256 checksum How to use checksums |
b52bd0f984ee6a0d151a278cb926431888e09c410c756045c5b8ba4731d8e415
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9
|
Release files / html2eml-0.0.5-py3-none-any.whl
| Download URL | html2eml-0.0.5-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
124378f2f11ea4f8fccaf0c927f317b6e826bf470dc9937b005f0c9f5d22fb66
|
|
BLAKE2b-256 checksum How to use checksums |
cc2e224cabe2bc3d58a902d17744e45c7e13303c2d0ad3059fa5acecdc14f7c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9
|
Security for html2eml 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.