A Python library to generate a signed email
Project description
python-smime-email
Generate x509 SMIME signed emails with ease!
Usage
-
Generate the email raw content
import smime_email data = b"Hello!" SMIME_KEY = smime_email.load_key("key_path.pem") SMIME_INTERMEDIATE = smime_email.load_certificates("intermediate_path.pem") SMIME_CERT = smime_email.load_certificates("cert_path.pem")[0] email_raw_bytes = smime_email.get_smime_attachment_content(data, SMIME_KEY, SMIME_INTERMEDIATE, SMIME_CERT)
-
Send it using any email library you like. Here is an example as Django email backend
email_raw_bytes = smime_email.get_smime_attachment_content(data, SMIME_KEY, SMIME_INTERMEDIATE, SMIME_CERT) # ... class EmailBackend(BaseEmailBackend): def send_messages(self, message) -> int: with smtplib.SMTP(settings.EMAIL_HOST, settings.EMAIL_PORT) as server: server.sendmail(message.from_email, message.to, email_raw_bytes) return 1
Development
The code is formatted with black and isort and checked with various linters.
To run the whole linting and formatting process, run poetry run poe all
.
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
smime_email-0.2.0.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for smime_email-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 403bc9614fde5b3610341fe5d840de4031c8ec4c36e775a3a32759f64e9ebd77 |
|
MD5 | 473d307c3dd75a9e039b95b367ba9e5f |
|
BLAKE2b-256 | 335de6bb0fcb8c06492d0b3625b90c8ae0aae0c762048514820075e62bd23cf2 |