You can setup your full(receiving and sending) mail server on Ubuntu using multiple software’s ie. Postfix, Dovecot and Roundcube. To receive your mails on Ubuntu server you need Dovecot, to send email from your server you need Postfix and to access your mail using web client you need Roundcube, you can also access your mails using third party clients like Thunderbird.
Prerequisites : Install LAMP server on Ubuntu
Step 1. Login to your linux machine.
Step 2. Install Packages for Postfix & Dovecot.
# apt-get install postfix postfix-mysql dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql -y
Select configuration type Internet Site:
Specify your fully qualified domain name(FDQN):
Step 3. Login into your Mysql Server.
# mysql -u root -p
Step 4. Create a new database for mailserver.
# create database servermail;
Step 5. Create a user for mysql & grant select privileges to that user with your desired password.
# GRANT SELECT ON servermail.* TO 'mailuser'@'127.0.0.1' IDENTIFIED BY 'mailuserpasswd';
Step 6. Flush privileges to apply changes.
# FLUSH PRIVILEGES;
Step 7. Use servermail database for creating tables.
# use servermail;
Step 8. Create a tables for mailserver.
To know more visit : How to Install Mail Server on Ubuntu