email.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/sh
  2. echo '\033[35m
  3. __ ______ ______
  4. / |/ / | / _/ /
  5. / /|_/ / /| | / // /
  6. / / / / ___ |_/ // /___
  7. /_/ /_/_/ |_/___/_____/
  8. \033[0m'
  9. echo "\033[35;1mEnable mail sending for php \033[0m"
  10. # TODO check if root
  11. # http://www.sycha.com/lamp-setup-debian-linux-apache-mysql-php#anchor13
  12. sleep 3
  13. apt-get --yes --force-yes install exim4
  14. echo "\033[35;1mConfiguring EXIM4 \033[0m"
  15. while [ "$configexim" != "y" ] && [ "$configexim" != "n" ]
  16. do
  17. echo -n "Should we configure exim4 ? [y|n] "
  18. read configexim
  19. done
  20. if [ "$configexim" = "y" ]; then
  21. echo "choose the first option :internet site; mail is sent and received directly using SMTP. Leave the other options as default exepted for domain name which should be valid domain name if you want your mails to not be considered as spam"
  22. echo "press any key to continue."
  23. read continu
  24. dpkg-reconfigure exim4-config
  25. else
  26. echo 'exim not configured'
  27. fi
  28. systemctl enable exim4
  29. systemctl restart exim4
  30. # dkim spf
  31. # https://debian-administration.org/article/718/DKIM-signing_outgoing_mail_with_exim4
  32. echo "\033[35;1mConfiguring DKIM \033[0m"
  33. while [ "$installdkim" != "y" ] && [ "$installdkim" != "n" ]
  34. do
  35. echo -n "Should we install dkim for exim4 ? [y|n] "
  36. read installdkim
  37. done
  38. if [ "$installdkim" = "y" ]; then
  39. echo -n "Choose a domain for dkim (same domain as you chose before for exim4): "
  40. read domain
  41. selector=$(date +%Y%m%d)
  42. mkdir /etc/exim4/dkim
  43. openssl genrsa -out /etc/exim4/dkim/"$domain"-private.pem 1024 -outform PEM
  44. openssl rsa -in /etc/exim4/dkim/"$domain"-private.pem -out /etc/exim4/dkim/"$domain".pem -pubout -outform PEM
  45. chown root:Debian-exim /etc/exim4/dkim/"$domain"-private.pem
  46. chmod 440 /etc/exim4/dkim/"$domain"-private.pem
  47. cp "$_cwd"/assets/exima4_dkim.conf /etc/exim4/conf.d/main/00_local_macros
  48. sed -ir "s/DOMAIN_TO_CHANGE/$domain/g" /etc/exim4/conf.d/main/00_local_macros
  49. sed -ir "s/DATE_TO_CHANGE/$selector/g" /etc/exim4/conf.d/main/00_local_macros
  50. update-exim4.conf
  51. systemctl restart exim4
  52. echo "please create a TXT entry in your dns zone : $selector._domainkey.$domain \n"
  53. echo "your public key is : \n"
  54. cat /etc/exim4/dkim/"$domain".pem
  55. echo "press any key to continue."
  56. read continu
  57. else
  58. echo 'dkim not installed'
  59. fi