I have set up postfix on a server, along with openDKIM.
When I run:
echo "Testing setup" | mail -s "Postfix test" {my_email_address}
I get the email, and in the mail headers there is a DKIM-Signature
header.
When, however I write a python script to send an email, using smtplib:
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.utils import make_msgid
msg = MIMEMultipart('alternative')
part1 = MIMEText('Hello, world', 'plain')
msg.attach(part1)
msg['From'] = 'alert@{my_domain}'
msg['To'] = '{my_email_address}'
msg['Subject'] = 'Test Email'
msg['Message-ID'] = make_msgid()
mailer = smtplib.SMTP('localhost')
mailer.sendmail('alert@{my_domain}', '{my_email_address}', msg.as_string())
mailer.quit()
The email that arrives in my inbox is missing the DKIM-Signature
header, and in the Authentication-Results
I see dkim=none (no signatures found);
So my question is: Do I need to sign my email manually (eg. with dkimpy), or is there some setting I can enable to have it signed for me?
Let me know if there is any extra information you want/need.