email.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. if [ "$EUID" -ne 0 ]; then
  11. echo "Please run as root"
  12. exit
  13. fi
  14. # http://www.sycha.com/lamp-setup-debian-linux-apache-mysql-php#anchor13
  15. sleep 2
  16. apt-get --yes --force-yes install exim4
  17. echo "\033[35;1mConfiguring EXIM4 \033[0m"
  18. while [ "$configexim" != "y" ] && [ "$configexim" != "n" ]
  19. do
  20. echo -n "Should we configure exim4 ? [y|n] "
  21. read configexim
  22. done
  23. if [ "$configexim" = "y" ]; then
  24. 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"
  25. echo "press any key to continue."
  26. read continu
  27. dpkg-reconfigure exim4-config
  28. else
  29. echo 'exim not configured'
  30. fi
  31. systemctl enable exim4
  32. systemctl restart exim4
  33. # dkim spf
  34. # https://debian-administration.org/article/718/DKIM-signing_outgoing_mail_with_exim4
  35. echo "\033[35;1mConfiguring DKIM \033[0m"
  36. while [ "$installdkim" != "y" ] && [ "$installdkim" != "n" ]
  37. do
  38. echo -n "Should we install dkim for exim4 ? [y|n] "
  39. read installdkim
  40. done
  41. if [ "$installdkim" = "y" ]; then
  42. echo -n "Choose a domain for dkim (same domain as you chose before for exim4): "
  43. read domain
  44. selector=$(date +%Y%m%d)
  45. mkdir /etc/exim4/dkim
  46. openssl genrsa -out /etc/exim4/dkim/"$domain"-private.pem 1024 -outform PEM
  47. openssl rsa -in /etc/exim4/dkim/"$domain"-private.pem -out /etc/exim4/dkim/"$domain".pem -pubout -outform PEM
  48. chown root:Debian-exim /etc/exim4/dkim/"$domain"-private.pem
  49. chmod 440 /etc/exim4/dkim/"$domain"-private.pem
  50. cp "$_cwd"/assets/exima4_dkim.conf /etc/exim4/conf.d/main/00_local_macros
  51. sed -ir "s/DOMAIN_TO_CHANGE/$domain/g" /etc/exim4/conf.d/main/00_local_macros
  52. sed -ir "s/DATE_TO_CHANGE/$selector/g" /etc/exim4/conf.d/main/00_local_macros
  53. update-exim4.conf
  54. systemctl restart exim4
  55. echo "please create a TXT entry in your dns zone : $selector._domainkey.$domain \n"
  56. echo "your public key is : \n"
  57. cat /etc/exim4/dkim/"$domain".pem
  58. echo "press any key to continue."
  59. read continu
  60. else
  61. echo 'dkim not installed'
  62. fi