You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 rivejä
1.4 KiB

  1. #!/bin/sh
  2. domain="$1"
  3. [ -z "$1" ] && exit
  4. domain="$1"
  5. subdom="mail"
  6. maildomain="$subdom.$domain"
  7. # Add the domain to the valid postfix addresses.
  8. grep -q "^mydestination.*$domain" /etc/postfix/main.cf ||
  9. sed -i "s/^mydestination.*/&, $domain/" /etc/postfix/main.cf
  10. # Create DKIM for new domain.
  11. mkdir -p "/etc/postfix/dkim/$domain"
  12. opendkim-genkey -D "/etc/postfix/dkim/$domain" -d "$domain" -s "$subdom"
  13. chgrp -R opendkim /etc/postfix/dkim/*
  14. chmod -R g+r /etc/postfix/dkim/*
  15. # Add entries to keytable and signing table.
  16. echo "$subdom._domainkey.$domain $domain:$subdom:/etc/postfix/dkim/$domain/$subdom.private" >> /etc/postfix/dkim/keytable
  17. echo "*@$domain $subdom._domainkey.$domain" >> /etc/postfix/dkim/signingtable
  18. systemctl reload opendkim postfix
  19. # Print out DKIM TXT entry.
  20. pval="$(tr -d '\n' <"/etc/postfix/dkim/$domain/$subdom.txt" | sed "s/k=rsa.* \"p=/k=rsa; p=/;s/\"\s*\"//;s/\"\s*).*//" | grep -o 'p=.*')"
  21. dkimentry="$subdom._domainkey.$domain TXT v=DKIM1; k=rsa; $pval"
  22. dmarcentry="_dmarc.$domain TXT v=DMARC1; p=reject; rua=mailto:dmarc@$domain; fo=1"
  23. spfentry="$domain TXT v=spf1 mx a:$maildomain -all"
  24. mxentry="$domain MX 10 $maildomain 300"
  25. echo "$dkimentry
  26. $dmarcentry
  27. $spfentry
  28. $mxentry" >> "$HOME/dns_emailwizard_added"
  29. echo "=== ADD THE FOLLOWING TO YOUR DNS TXT RECORDS ==="
  30. echo "$dkimentry
  31. $dmarcentry
  32. $spfentry
  33. $mxentry"
  34. echo "They have also been stored in ~/dns_emailwizard_added"