Setting up dkim & spf with amavis on Ubuntu 16.04

  • mkdir -p /etc/dkim/
  • amavisd-new genrsa /etc/dkim/domain.ninja.key.pem (change domain.ninja to your domain)
  • insert below code into nano /etc/amavis/conf.d/50-userand change domain.ninja there
  • amavisd-new showkeys (shows your public key for dns record)
  • Copy the content into your domain DNS record as a TXT record foo._domainkey.domain.ninja. to name and everything between () in text
  • add spf like this "v=spf1 mx a ptr ~all" to a TXT record
  • test if it works with amavisd-new testkeys
  • service amavis restart to restart service
  • send a email to check-auth@verifier.port25.com to check if dkim is working

Sources: Faqforge, ServerFault