All Projects → balena → python-smime

balena / python-smime

Licence: Apache-2.0 license
S/MIME encoder in pure python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to python-smime

Mailkit
A cross-platform .NET library for IMAP, POP3, and SMTP.
Stars: ✭ 4,477 (+27881.25%)
Mutual labels:  email, smime
attachment-downloader
Simple tool for downloading email attachments for all emails in a given folder using an IMAP client
Stars: ✭ 52 (+225%)
Mutual labels:  email
email
Aplus Framework Email Library
Stars: ✭ 127 (+693.75%)
Mutual labels:  email
apiservices
.NET API services - Managed Push Notifications, Email Engine (Templates, loading, & sending), & Localization Abstractions
Stars: ✭ 25 (+56.25%)
Mutual labels:  email
laravel-postal
This library integrates Postal with the standard Laravel mail framework.
Stars: ✭ 20 (+25%)
Mutual labels:  email
matrix-email-bot
A bot that posts messages to rooms when an email is received.
Stars: ✭ 33 (+106.25%)
Mutual labels:  email
mailbag
A tool for creating and managing Mailbags, a package for preserving email using multiple preservation formats
Stars: ✭ 29 (+81.25%)
Mutual labels:  email
Smart-Mass-Mailer
Smart Bulk Email Sender with Mail Merge, Delay between Emails and HTML Content
Stars: ✭ 51 (+218.75%)
Mutual labels:  email
emil
Emil is a library for dealing with E-Mail in Scala.
Stars: ✭ 17 (+6.25%)
Mutual labels:  email
ogham
Sending email, sms or whatever is a piece of cake
Stars: ✭ 19 (+18.75%)
Mutual labels:  email
cerb-release
For over 20 years, teams of all sizes have used Cerb to manage their email workloads. Whether you're a solo founder replying to a few support messages per day, or a team with hundreds of members replying to thousands of messages per hour, you can serve your audience faster with Cerb's time-tested tools. Development at: https://github.com/jstande…
Stars: ✭ 37 (+131.25%)
Mutual labels:  email
terraform-aws-ses-dashboard
This module will create a Deliverability Dashboard that shows information about SES Email bounces and complaints.
Stars: ✭ 20 (+25%)
Mutual labels:  email
mail
Actively maintained fork of gomail. The best way to send emails in Go.
Stars: ✭ 376 (+2250%)
Mutual labels:  email
nest-sendgrid
No description or website provided.
Stars: ✭ 24 (+50%)
Mutual labels:  email
django-des
Django Dynamic Email Settings - Change your email configuration without interrupting service.
Stars: ✭ 28 (+75%)
Mutual labels:  email
flutter mailer
A wrapper on top of MFMailComposeViewController from iOS and Mail Intent on android
Stars: ✭ 43 (+168.75%)
Mutual labels:  email
protocol
OpenCAP: Making Crypto Convenient
Stars: ✭ 32 (+100%)
Mutual labels:  email
sesdashboard
Analytics and activity tracking dashboard for AWS Simple Email Service
Stars: ✭ 36 (+125%)
Mutual labels:  email
twitter-digest
✉️ A netlify lambda function that emails you tweets from a twitter list.
Stars: ✭ 14 (-12.5%)
Mutual labels:  email
EmailValidationPascal
Simple Class for Validating Email Address Syntax in Pascal/Delphi
Stars: ✭ 32 (+100%)
Mutual labels:  email

Python S/MIME Toolkit

This library implements a S/MIME handler. It supports only S/MIME messages encryption using a public RSA key, in AES128-CBC, AES192-CBC or AES256-CBC modes.

The ASN.1 implementation does not depend on pyasn1, as it showed too broken for creating and reading CMS (Cryptographic Message Syntax). Instead, the asn1crypto was used in this project.

This implementation does not use the deprecated pycrypto anymore; instead it was switched to the more modern cryptography library. It is not 'pure python' anymore (because of the latter dependency), but at least works.

Requirements

  • Python 2.7 or Python 3.5+
  • cryptography
  • asn1crypto

Example

The code below loads Alice's public key in PEM format and uses it to encrypt the e-mail in S/MIME format:

import sys
import smime

message = [
    'To: "Alice" <[email protected]>',
    'From: "Bob" <[email protected]>',
    'Subject: A message from python',
    '',
    'Now you see me.'
]

with open('alice-public-key.pem', 'rb') as pem:
    print(smime.encrypt('\n'.join(message), pem.read()))

Output:

To: "Alice" <[email protected]>
From: "Bob" <[email protected]>
Subject: A message from python
MIME-Version: 1.0
Content-Type: application/pkcs7-mime; smime-type=enveloped-data; name=smime.p7m
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=smime.p7m

<base64-enveloped-data>

The same can be decrypted using OpenSSL from the command line:

$ openssl smime -decrypt -in smime.p7m -inkey alice-private-key.pem

OpenSSL expects that the smime.p7m file above should be in DER or PEM format. The latter should be enclosed in -----BEGIN PKCS7----- and -----END PKCS7----- and the content should be in base64 encoding, just like the output of the command above. Example:

-----BEGIN PKCS7-----
MIIBdgYJKoZIhvcNAQcDoIIBZzCCAWMCAQAxgb4wgbsCAQAwJjASMRAwDgYDVQQD
EwdDYXJsUlNBAhBGNGvHgABWvBHTbi7EELOwMAsGCSqGSIb3DQEBAQSBgCVAQwNg
LmJ5ESYxOM1YbOLz2gvzWY1Fk+LZZiylYe7+o1/e/MjtzNwhnu+8vziFwHbXEH1Y
jndIbUxiLyXb3omtNDunRICQin5bdo6BI7oE0MufUSqMjk0YUk8UQeNCiUfK89PR
RfDclb1/sM3XZ7mUJa2OzpnuQIWec3MuJ3k4MIGcBgkqhkiG9w0BBwEwHQYJYIZI
AWUDBAEqBBCVZVOt2lxSzmd+Ti1M372xgHDR0+ToLk1MJeTTtmJdnnNNH6631PN0
i3NJeJBKDDs4onI8xywqFtJP0of6GPoTGV/7D2vkgO2+jhCBTrzjYczbdOhh6Z5X
o0i/81NPSoaLhrfwKMQvT7sXX7c9YdbTjyglyGqhXUN8h+mIRlP9IStD
-----END PKCS7-----

Remember that the above formatting serves only for the purpose of testing the encryption with OpenSSL. Do not make such enclosing in e-mails.

License

This software is licensed under the Apache License 2.0. See the LICENSE file in the top distribution directory for the full license text.

Versioning

This software follows Semantic Versioning

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].