Skip to content

Adding Your Own DKIM Signatures

You can choose to add your own DKIM signatures to email sent through Sendamatic instead of using our managed signatures. This allows you greater control and customization of the DKIM authentication process.

When adding your own signatures:

  • Ensure the private key and selector you use matches the public key published in your DNS records. Any mismatches will cause authentication failures.
  • Our systems automatically may add or alter values for some headers. Do not sign these headers:

    • CFBL-Address
    • CFBL-Feedback-ID
    • Date
    • List-Unsubscribe (if enabled)
    • Message-ID
    • Return-Path
  • You can disable Sendamatic's default DKIM signing if you only want to rely on your own signatures. Do this within your "Mail Identity" settings.

If you encounter delivery issues after adding custom DKIM signatures, you may need to check that the signatures are being formed correctly. Tools such as appmaildev.com's DKIM Test can help validate your configuration, and debug any issues.

Example

# DKIM message signing using dkimpy
import smtplib, dkim

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

msg = MIMEMultipart('alternative')
msg['From'] = '[email protected]'
msg['To'] = '[email protected]'
msg['Subject'] = 'Test Subject'

msg.attach(MIMEText("Text part", 'plain'))
msg.attach(MIMEText("<b>HTML</b> part", 'html'))

# Sign the mail
headers_to_sign = [b'from', b'to', b'subject']

signature = dkim.sign(msg.as_bytes(), b'dkimselector', b'example.com', private_key.encode(), include_headers=headers_to_sign)
signature = signature.decode()

msg['DKIM-Signature'] = signature[len("DKIM-Signature: "):]

# Send the mail
server = smtplib.SMTP('in.smtp.sendamatic.net', 587)
server.ehlo()
server.starttls()
server.login(username, password)
server.sendmail(msg['From'], msg['To'], msg.as_string())
server.quit()