I am new to Python and am trying to create an email that sends a script through a socket connection but cannot sign it with dkimpy lib. I tried a couple of examples on the Internet, but everyone returned the same error when starting dkim.sign:
File "C:\Python34\lib\re.py", line 196, in split return _compile(pattern,flags).split(string, maxsplit)
TypeError: expected string or buffer
Nearby, as I can tell, the first variable in the dkim.sign function should be a string, so I tried readlines () and even .as_string () to be sure. I checked the message and seems to be compatible with RFC822. But I will double check if anyone is thinking what might be the problem. Without dkim.sign, it works fine (minus any protection like SPF / DKIM)
This is the code snippet I'm using:
f=open('mail.htm','r')
text=MIMEText(f.read(),'html')
headers = Parser().parse(open('mail.htm', 'r'))
sender=headers['From']
receiver=headers['To']
subj=headers['Subject']
f.close()
private_key = open('default.pem').read()
headers = ['To', 'From', 'Subject']
sig = dkim.sign(text, 'default', '<mydomain.here>', private_key, include_headers=headers)
script. dkim , , .
?
EDIT: , ( ) dkim.rfc822_parse dkimpy lib, :
return _compile(pattern, flags).split(string, maxsplit)
TypeError: can't use a bytes pattern on a string-like object
, , ?
FIXED: , private_key. Win , Windows , vim nano . MCEdit .
:)