diff --git a/src/content/docs/ispmail-bookworm/100-postfix-access-mariadb.mdx b/src/content/docs/ispmail-bookworm/100-postfix-access-mariadb.mdx index 24cb994..26705a6 100644 --- a/src/content/docs/ispmail-bookworm/100-postfix-access-mariadb.mdx +++ b/src/content/docs/ispmail-bookworm/100-postfix-access-mariadb.mdx @@ -44,4 +44,59 @@ postmap -q example.org mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf If you get an error like “postmap: warning: connect to mysql server 127.0.0.1: Access denied for user ‘mailserver’@’localhost'” then please double check the password of the ‘mailserver’ database user. It is either wrong in the CF file or you did not create the database user correctly using the GRANT query on the previous page. -You should get ‘1’ as a result. That means your first mapping is working. Feel free to try that with other domains after the `-q` in that line. You should not get a response. \ No newline at end of file +You should get ‘1’ as a result. That means your first mapping is working. Feel free to try that with other domains after the `-q` in that line. You should not get a response. + +## virtual\_mailbox\_maps + +You will now define the _virtual\_mailbox\_maps_. It will map a recipient’s email address (left-hand side) to the location of the user’s mailbox on your hard disk (right-hand side). Postfix has a built-in transport service called “virtual” that can receive the email and store it into the recipient’s email directory. That service is pretty limited, so we will delegate that to Dovecot as it allows us better control. + +Postfix will forward all emails to Dovecot for further delivery. But we need to make sure that the recipient actually exists before we do that. So Postfix needs to check whether an email address belongs to a valid mailbox. That simplifies things a bit because we just need the left-hand side of the mapping. + +Similar to the above virtual\_domains mapping you need an SQL query that searches for an email address and returns “1” if it is found. + +To accomplish that please create another configuration file at `/etc/postfix/mysql-virtual-mailbox-maps.cf`: + +
+user = mailserver
+password = **x893dNj4stkHy1MKQq0USWBaX4ZZdq**
+hosts = 127.0.0.1
+dbname = mailserver
+query = SELECT 1 FROM virtual_users WHERE email='%s'
+
+ +Again please use your actual password for the ‘mailserver’ database user. + +Tell Postfix that this mapping file is supposed to be used for the virtual\_mailbox\_maps mapping: + +
+postconf virtual_mailbox_maps=mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
+
+ +Test if Postfix is happy with this mapping by asking it where the mailbox directory of our `john@example.org` user would be: + +## virtual\_alias\_maps + +The virtual\_alias\_maps mapping is used for forwarding emails from one email address to one or more others. In the database multiple targets are achieved by using multiple rows. + +Create another “.cf” file at `/etc/postfix/mysql-virtual-alias-maps.cf`: + +
+user = mailserver
+password = **x893dNj4stkHy1MKQq0USWBaX4ZZdq**
+hosts = 127.0.0.1
+dbname = mailserver
+query = SELECT destination FROM virtual\_aliases WHERE source='%s'
+
+ +Make Postfix use this database mapping: +``` +postconf virtual_alias_maps=mysql:/etc/postfix/mysql-virtual-alias-maps.cf +``` +Test if the mapping file works as expected: +``` +postmap -q jack@example.org mysql:/etc/postfix/mysql-virtual-alias-maps.cf +``` +You should see the expected destination: + +`john@example.org` + diff --git a/src/content/docs/ispmail-bookworm/70-install-the-software-packages copy.mdx b/src/content/docs/ispmail-bookworm/70-install-the-software-packages copy.mdx index 1a796e4..f3c69c6 100644 --- a/src/content/docs/ispmail-bookworm/70-install-the-software-packages copy.mdx +++ b/src/content/docs/ispmail-bookworm/70-install-the-software-packages copy.mdx @@ -96,7 +96,7 @@ root@buster:~# mysql Server version: 10.3.18-MariaDB-0+deb10u1 Debian 10 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. - MariaDB \[(none)\]> + MariaDB [(none)]> ``` Exit the SQL shell by typing “exit” or pressing CTRL-D.