Yum Install Dovecot Mariadb-Server Dovecot-Mysql Mariadb
Yum Install Dovecot Mariadb-Server Dovecot-Mysql Mariadb
MariaDB
In this section you will set up a MariaDB database to store virtual domains, users and passwords.
Dovecot and Postfix require this data.
2. Use the mysql_secure_installation tool to configure additional security options. This tool
will ask if you want to set a new password for the MySQL root user, but you can skip that
step:
sudo mysql_secure_installation
4. Log in to MySQL:
sudo mysql -u root -p
5. Create the MySQL user and grant the new user permissions over the database. Replace
mailuserpass with a secure password:
GRANT SELECT ON mailserver.* TO 'mailuser'@'127.0.0.1' IDENTIFIED BY
'mailuserpass';
Adding Data
You can now add data to the database and tables that were created in the previous section.
1. Add the domains to the virtual_domains table. Replace the values for example.com
and hostname with your own settings:
INSERT INTO `mailserver`.`virtual_domains`
(`id` ,`name`)
VALUES
('1', 'example.com'),
('2', 'hostname.example.com'),
('3', 'hostname'),
('4', 'localhost.example.com');
Note
Note which id corresponds to which domain, the id value is necessary for the
next two steps.
2. Add email addresses to the virtual_users table. The domain_id value references the
virtual_domain table’s id value. Replace the email address values with the addresses
that you wish to configure on the mailserver. Replace the password values with strong
passwords.
INSERT INTO `mailserver`.`virtual_users`
(`id`, `domain_id`, `password` , `email`)
VALUES
('1', '1', ENCRYPT('password', CONCAT('$6$', SUBSTRING(SHA(RAND()), -
16))), '[email protected]'),
('2', '1', ENCRYPT('password', CONCAT('$6$', SUBSTRING(SHA(RAND()), -
16))), '[email protected]');
3. An email alias will forward all email from one email address to another. To set up an email
alias, add it to the virtual_aliases table:
INSERT INTO `mailserver`.`virtual_aliases`
(`id`, `domain_id`, `source`, `destination`)
VALUES
('1', '1', '[email protected]', '[email protected]');
Testing
In the previous section, data was added to the MySQL mailserver database. The steps below
will test that the data has been stored and can be retrieved.
1. Log in to MySQL:
sudo mysql -u root -p
3. Verify that the output displays the domains you add to the virtual_domains table:
+----+-----------------------+
| id | name |
+----+-----------------------+
| 1 | example.com |
| 2 | hostname.example.com |
| 3 | hostname |
| 4 | localhost.example.com |
+----+-----------------------+
4 rows in set (0.00 sec)
5. Verify that the output displays the email addresses you added to the virutal_users
table. Your hashed passwords will appear longer than they are displayed below:
+----+-----------+-------------------------------------
+--------------------+
| id | domain_id | password | email
|
+----+-----------+-------------------------------------
+--------------------+
| 1 | 1 | $6$574ef443973a5529c20616ab7c6828f7 |
[email protected] |
| 2 | 1 | $6$030fa94bcfc6554023a9aad90a8c9ca1 |
[email protected] |
+----+-----------+-------------------------------------
+--------------------+
2 rows in set (0.01 sec)
7. Verify that the output displays the aliases you added to the virtual_aliases table:
+----+-----------+-------------------+--------------------+
| id | domain_id | source | destination |
+----+-----------+-------------------+--------------------+
| 1 | 1 | [email protected] | [email protected] |
+----+-----------+-------------------+--------------------+
1 row in set (0.00 sec)