Title: Verifying if an email contains a s/mime in python
Tags: python;smime
Question: Is it possible, using python without os calls, to detect if an incoming email message is signed ? (Don't care about the certificate validity, I just want to know if the message contains a signed content)

The corresponding openssl command I'd like to reproduce is the following:

```openssl smime -verify -in /tmp/mails/d4fa5d0f-2250-4acd-8d3d-14c4e9743392```

I can run ```os.system('openssl smime -verify -in /tmp/mails/d4fa5d0f-2250-4acd-8d3d-14c4e9743392')``` but I would like to use a python lib instead if possible.

All the examples I have found implies that I have a public key to decode the certificate, I only want to know if the email contains a signed content or not.

Comment: What about https://pypi.python.org/pypi/pyOpenSSL

Comment: It is possible without calling `openssl`. Just use a openssl library inside python.


Here is another answer: ```import email


msg = email.message_from_file(open('/home/mailuser/testmail.mail'))
if 'signed' in msg.get_content_type():
    <your code here&gt;
```

...works for me


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2016:00:02/02/16', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<python><smime>', 'Title': 'Verifying if an email contains a s/mime in python', 'ViewCount': 300, 'id': 35158789, 'user_AboutMe': '', 'user_AccountId': 159596.0, 'user_DisplayName': 'kitensei', 'user_Reputation': 2450.0, 'user_Views': 247.0, 'user_id': 379105.0}}