#http://www.tecmint.com/setup-postfix-mail-server-in-ubuntu-debian/
apt update && apt upgrade -y
apt-get install apache2 php5
apt-get install postfix bsd-mailx
#internet facing
service postfix restart
apt-get install dovecot-imapd dovecot-pop3d
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
apt-get install squirrelmail
squirrelmail-configure
#enter “2” in order to edit the server settings, and you will be prompted to it.
#enter “1” in order to change the domain name and write up your domain (e.g: example.com).
#Go back to the main menu by writing “R” and hitting the enter key, write “4” in order to configure the general options.
#You see “Allow server-side sorting”? Enter “11” and change it from “false” to “true” by entering “y”. Now hit the Enter key, and enter the “S” key in order to save the configuration file.
cp /etc/squirrelmail/apache.conf /etc/apache2/sites-available/squirrelmail.conf
a2ensite squirrelmail.conf
#You can now access the mail server by going to example.com/squirrelmail.
####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
#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 :)