#http://www.tecmint.com/setup-postfix-mail-server-in-ubuntu-debian/ apt update && apt upgrade -y apt-get install -y postfix bsd-mailx dovecot-imapd dovecot-pop3d procmail #internet facing service postfix restart service dovecot restart chmod 1777 /var/mail #to allow deleting of mail vim /etc/postfix/master.cf #change line to be fifo for mailx pickup fifo n - - 60 1 pickup ####Creating Mail Users#### useradd myusername passwd myusername mkdir -p /var/www/html/myusername usermod -m -d /var/www/html/myusername myusername chown -R myusername:myusername /var/www/html/myusername #open ports iptables -A INPUT -p tcp --dport 25 -j ACCEPT iptables -A INPUT -p tcp --dport 110 -j ACCEPT iptables -A INPUT -p tcp --dport 143 -j ACCEPT iptables -A INPUT -p tcp --dport 993 -j ACCEPT iptables -A INPUT -p tcp --dport 995 -j ACCEPT #setup virtual mail boxes vim /etc/postfix/virtual myusername@domain myusername postmap /etc/postfix/virtual vim /etc/postfix/main.cf virtual_alias_maps = hash:/etc/postfix/virtual service postfix reload vim /etc/postfix/main.cf mailbox_command = procmail -a "$EXTENSION" service postfix reload #####Procmail will not send to root and will go to /var/mail/nobody#### #if you want mail to go to users home dir vim /etc/procmailrc DEFAULT=$HOME/mail/ #mail is in /var/spool or /var/mail #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 :)