Skip to main content

A Python library to generate a signed email

Project description

python-smime-email

PyPI Downloads

Generate x509 SMIME signed emails with ease!

Usage

  1. 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)
    
  2. 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 ruff and checked with various linters. To run the whole linting and formatting process, run poetry run poe all.

License

Code and documentation copyright 2024 Siemens AG.

See LICENSE.md.

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

smime_email-1.0.1.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

smime_email-1.0.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file smime_email-1.0.1.tar.gz.

File metadata

  • Download URL: smime_email-1.0.1.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for smime_email-1.0.1.tar.gz
Algorithm Hash digest
SHA256 26e54546f92cde2350fb6d1c3a7b321e039590c86f1ab3df27ac43e058965ba3
MD5 ae833cf6295e7c0657cf8e08412ffa12
BLAKE2b-256 4f2fd01148bf8464e9eef4802ac60a1483346b231e9814c70f8049da2b696b35

See more details on using hashes here.

Provenance

The following attestation bundles were made for smime_email-1.0.1.tar.gz:

Publisher: publish.yml on siemens/python-smime-email

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

File details

Details for the file smime_email-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: smime_email-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for smime_email-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9e9588489e077c9466c7a9ea95d40c1cb1ba9b74ee8240a49a61d68320f77da5
MD5 31eea410ae8499fd882f47e188da1e2b
BLAKE2b-256 55966e2befb0d9c28f727556a32808a16a1704f83095e5b0a79c8e3599a17c23

See more details on using hashes here.

Provenance

The following attestation bundles were made for smime_email-1.0.1-py3-none-any.whl:

Publisher: publish.yml on siemens/python-smime-email

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 Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page