You can setup your full(receiving and sending) mail server on Centos using multiple software’s ie. Postfix, Dovecot and Roundcube. To receive your mails on Centos 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 : https://www.cloudjojo.com/how-to-install-apache-mariadb-php-lamp-on-centos-7/
Step 1. Login to your linux machine.
Step 2. Install Packages for Postfix & Dovecot.
# yum install postfix* dovecot* dovecot-mysql sendmail -y
Step 3. Login into your Mysql Server.
# mysql -u root -p
Step 4. Create a new database for mailserver.
MariaDB [(none)]> create database servermail;
Step 5. Create a user for mysql & grant select privileges to that user with your desired password.
MariaDB [(none)]> GRANT SELECT ON servermail.* TO 'mailuser'@'127.0.0.1' IDENTIFIED BY 'mailuserpasswd';
Step 6. Flush privileges to apply changes.
MariaDB [(none)]> FLUSH PRIVILEGES;
Step 7. Use servermail database for creating tables.
MariaDB [(none)]> use servermail;
Step 8. Create a tables for mailserver.
Create a table for domain that will receive mail:
MariaDB [servermail]> CREATE TABLE `virtual_domains` ( `id` int(10) NOT NULL auto_increment, `name` varchar(40) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Create a table to add Email address & Password:
MariaDB [servermail]> CREATE TABLE `virtual_users` ( `id` INT NOT NULL AUTO_INCREMENT, `domain_id` INT NOT NULL, `password` varchar(106) NOT NULL, `email` varchar(120) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `email` (`email`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Create a table to add virtual aliases:
MariaDB [servermail]> CREATE TABLE `virtual_aliases` ( `id` INT NOT NULL AUTO_INCREMENT, `domain_id` INT NOT NULL, `source` varchar(100) NOT NULL, `destination` varchar(100) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Step 9. Adding data into tables.
Adding domains in virtual_domain table & make sure to replace examplenet.xyz with your domain name:
MariaDB [servermail]> INSERT INTO `servermail`.`virtual_domains`
(`id` , `name`)
VALUES
('1', 'examplenet.xyz');
Adding email address in virtual_users table.Make sure to replace domain name & mailuserpassword with your settings:
MariaDB [servermail]> INSERT INTO `servermail`.`virtual_users` (`id` , `domain_id` , `password` , `email`) VALUES ('1', '1', MD5('mailuserpasswd'), '[email protected]');
Adding Email Alias in Virtual_aliases table:
MariaDB [servermail]> INSERT INTO `servermail`.`virtual_aliases` (`id`, `domain_id`, `source`, `destination`) VALUES ('1', '1', '[email protected]', '[email protected]');
Step 10. Now we are going to test contents of every servermail tables.
Test the content of virtual_domain table:
# select * from servermail.virtual_domains;
Test the content of virtual_users table:
# select * from servermail.virtual_users;
Test the content of virtual_aliases table:
# select * from servermail.virtual_aliases;
Step 11. Exit from Mysql.
# exit
Click below link to see further Installation & Configuration of Mail Server:
https://www.cloudjojo.com/how-to-install-mail-server-on-centos-7part-2-dovecot-postfix/