Skip to content

Instantly share code, notes, and snippets.

@denysvitali
Created December 18, 2016 17:24
Show Gist options
  • Save denysvitali/8082ef783e5e9e2b763d24b956ad0309 to your computer and use it in GitHub Desktop.
Save denysvitali/8082ef783e5e9e2b763d24b956ad0309 to your computer and use it in GitHub Desktop.
#!/bin/bash
clear
echo "----------------------"
echo "DKIM setter by denv.it"
echo "----------------------"
default="denv.it"
read -p "Inserisci il nome del dominio [$default]: " domain_name
domain_name=${domain_name:-$default}
echo $domain_name
cd "/etc/opendkim/keys"
opendkim-genkey -s "mail" -d "${domain_name}"
mv "mail.txt" "${domain_name}.txt"
mv "mail.private" "${domain_name}.private"
chown opendkim:opendkim "${domain_name}.private" "${domain_name}.txt"
file=/etc/opendkim.conf
echo "" >> ${file}
echo "# DKIM_SETTER (${domain_name})" >> ${file}
echo "Domain ${domain_name}" >> ${file}
echo "KeyFile /etc/opendkim/keys/${domain_name}.private" >> ${file}
echo "Selector mail" >> ${file}
echo "SOCKET inet:8891@localhost" >> ${file}
echo "# END ${domain_name}" >> ${file}
echo "" >> ${file}
service postfix restart
service opendkim restart
echo -e "Importante! Aggiungi il seguente record ai DNS:\n"
cat "${domain_name}.txt"
echo -e "\nPoi il record TXT _dmarc.${domain_name} con valore \"v=DMARC1; p=none\""
echo -e "\nE non dimenticare il record SPF @ con valore \"v=spf1 mx a ip4:185.53.131.229 ~all\"!"
echo -e "\nUna volta apportate le modifiche ai DNS attendi 5 minuti oppure esegui il comando \"bash ~/scripts/dns-set.sh\""
echo -e "\nFine, ora prova la mail con http://www.mail-tester.com/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment