How to install mail server on Ubuntu
This long post contains a recipe for building a reasonably secure Ubuntu 16.04 mail server in Amazon Web Services, using Postfix, Dovecot, and MySQL, with anti-spam packages in the form of amavisd-new, Clam AntiVirus, SpamAssassin, and Postgrey. Local users are virtual rather than being system users. Administration of users and domains is achieved through the Postfix Admin web interface. Webmail is provided by Roundcube.
This is an updated version of earlier Ubuntu 12.04 and Ubuntu 14.04 mailserver recipes. A number of people graciously helped to fix bugs and make improvements in the original, so should you find a blocking issue here please do let me know.
In case, you get error with permission, try to do with this:
Created a separate user/group named "vmail" with an id 5000 and changed the mail folders ownerships to that.
[email protected]:~# groupadd -g 5000 vmail
[email protected]:~# useradd -g vmail -u 5000 vmail -d /var/vmail
[email protected]:~# chown -R vmail:vmail /var/vmail