Ok, so I am not completely lost with DKIM. I know the general rules of encoding and setting DNS records with your public key, etc. What I am having issues with is incorporating the "on the fly" signing of outbound emails and injecting into my header because my MTA it is custom, written in python from the ground up, not out of the box. Wondering if anyone had a small python example of sending even 1 email with DKIM, and going through all the motions. Like generating the 256 bit crypto body using your private key that matches the sister (public) key in your dns settings.
This should help.
I looked at the tests and the command line tools included in the project to learn how to use it.
Here is a code fragment which will give you an idea of how to use it. Sorry I can't provide more.
self.dkim_private = open(os.path.join(settings.PROJECT_DIR, 'private_key.pem')).read()
... snip ...
msg = MIMEMultipart('alternative')
msg['From'] = "{0} <{1}>".format(self.sendfrom_name, self.sendfrom)
msg['To'] = self.sendto
msg['Date'] = formatdate(localtime=True)
msg['Message-ID'] = self.message_id
msg['Subject'] = self.subject
msg.attach(MIMEText(unicodedata.normalize('NFKD', self.body_text), 'plain'))
msg.attach(MIMEText(self.body, 'html'))
sig = dkim.sign(msg.as_string(), 'myselector',
from_domain, self.dkim_private,
include_headers=['from', 'to', 'subject', 'message-id'])
msg['DKIM-Signature'] = sig[len("DKIM-Signature: "):]
Then you use can use smtplib to send the email.
The private and public keys can be generated easily here: