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.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for smime_email-1.0.0.tar.gz
Algorithm Hash digest
SHA256 04d14f60ed7feca724108aac9ce970c67409bf5e2fa467f3a3c7d02a84668372
MD5 4151a97d679ba8649b5a61c7968c2e26
BLAKE2b-256 8e31825f10a0c44c3cd697f80d40619e5c0a3da8176f6d66303c62bf6f77d1bc

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for smime_email-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d164acdfda5884c55a86f614dde4108acf6fe92a8971e9ff86a9cf526e97f7b
MD5 8664fd4bd9e42f6f61301d0c5280e4ec
BLAKE2b-256 b52262e779284a03893352bc03dea121f2b8dc6537a143c554a77d91a6077202

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page