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 uv run poe all.

License

Code and documentation copyright 2024-2025 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.3.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

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

smime_email-1.0.3-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for smime_email-1.0.3.tar.gz
Algorithm Hash digest
SHA256 9f3c03fa1278d7acb1312c590f8d5467b3f46284a2dc512cb9bdb4e56103500a
MD5 29c929d136ffe0f4f2f0a0d5521d5568
BLAKE2b-256 3bb832261a92a80ea182f15f9810e31b8e24c1364718b054822902ba1a982b62

See more details on using hashes here.

Provenance

The following attestation bundles were made for smime_email-1.0.3.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.3-py3-none-any.whl.

File metadata

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

File hashes

Hashes for smime_email-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3fb1a6628c04f2c128244ed8b7c2b340b7328590fa2f46e62143da6cb2ed5b87
MD5 3e248ee27c1bc7b107420b14fbe4e050
BLAKE2b-256 af0abf311097997f642f9b0cec45aee5e2832b715255384240dee348d358ce7e

See more details on using hashes here.

Provenance

The following attestation bundles were made for smime_email-1.0.3-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 Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page