title: Decrypt string using Python M2Crypto
body: <p>I am trying to decrypt an email message in python using M2Crypto.  The problem I have is the examples I find online all seem to read in a file.  But in my code I have a string that contains the body of an email.  So I am passing in the body of the email.</p>
  
  <p>Here is the code I am basing my program from:</p>
  
  <p><code>
      from M2Crypto import BIO, SMIME, X509</p>
  
  <pre><code>def decryptMessage(body):
    # Instantiate an SMIME object.
    s = SMIME.SMIME()
  
    # Load private key and cert.
    s.load_key('recipient_key.pem', 'recipient.pem')
  
    # Load the encrypted data.
    p7, data = SMIME.smime_load_pkcs7(body)
  
    # Decrypt p7.
    out = s.decrypt(p7)
  
    return out.read()
  </code></pre>
  
  <p></code></p>
  
  <p>When I do this, I get an error that says "File name too long"</p>
  
  <p>Can someone help me understand how to decrypt a string from my email?</p>