https://github.com/siemens/python-smime-email
Generate x509 SMIME signed emails with ease!
https://github.com/siemens/python-smime-email
Last synced: 5 months ago
JSON representation
Generate x509 SMIME signed emails with ease!
- Host: GitHub
- URL: https://github.com/siemens/python-smime-email
- Owner: siemens
- License: mit
- Created: 2024-10-04T12:48:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-24T12:31:08.000Z (9 months ago)
- Last Synced: 2025-08-17T22:42:12.533Z (5 months ago)
- Language: Python
- Homepage:
- Size: 69.3 KB
- Stars: 4
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE-OF-CONDUCT.md
- Codeowners: CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# python-smime-email
Generate x509 SMIME signed emails with ease!
## Usage
1. Generate the email raw content
```python
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)
```
1. Send it using any email library you like. Here is an example as Django email backend
```python
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](LICENSE.md).