Advertisement
metalx1000

Postfix mail server setup

Oct 24th, 2016 (edited)
1,613
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.51 KB | None | 0 0
  1. #http://www.tecmint.com/setup-postfix-mail-server-in-ubuntu-debian/
  2. apt update && apt upgrade -y
  3. apt-get install -y postfix bsd-mailx dovecot-imapd dovecot-pop3d procmail
  4. #internet facing
  5. service postfix restart
  6. service dovecot restart
  7. chmod 1777 /var/mail #to allow deleting of mail
  8.  
  9. vim /etc/postfix/master.cf #change line to be fifo for mailx
  10. pickup    fifo  n       -       -       60      1       pickup
  11.  
  12. ####Creating Mail Users####
  13. useradd myusername
  14. passwd myusername
  15. mkdir -p /var/www/html/myusername
  16. usermod -m -d /var/www/html/myusername myusername
  17. chown -R myusername:myusername /var/www/html/myusername
  18.  
  19. #open ports
  20. iptables -A INPUT -p tcp --dport 25 -j ACCEPT
  21. iptables -A INPUT -p tcp --dport 110 -j ACCEPT
  22. iptables -A INPUT -p tcp --dport 143 -j ACCEPT
  23. iptables -A INPUT -p tcp --dport 993 -j ACCEPT
  24. iptables -A INPUT -p tcp --dport 995 -j ACCEPT
  25.  
  26. #setup virtual mail boxes
  27. vim /etc/postfix/virtual
  28. myusername@domain myusername
  29. postmap /etc/postfix/virtual
  30. vim /etc/postfix/main.cf
  31. virtual_alias_maps = hash:/etc/postfix/virtual
  32. service postfix reload
  33.  
  34. vim /etc/postfix/main.cf
  35. mailbox_command = procmail -a "$EXTENSION"
  36. service postfix reload
  37. #####Procmail will not send to root and will go to /var/mail/nobody####
  38.  
  39. #if you want mail to go to users home dir
  40. vim /etc/procmailrc
  41. DEFAULT=$HOME/mail/
  42.  
  43. #mail is in /var/spool or /var/mail
  44. #If you faced any other error.. Just check the “/var/log/mail.log” file, all the error message will be stored there, you won’t lose your way :)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement