It is important to understand how postfix implements mappings. The core of our system is the postfix mapping, where we discuss this issue and don't skip this part. The usual literal meaning of a mapping is to establish a relationship between two values. We must map the Mail user account or email address in postfix. For example, the local alias used by Postfix and the Local System user mapping file:/etc/aliases, shows the mapping structure:
Postmaster:root
This mapping structure causes all letters sent to Postmaster@yourdomain.tld to be redirected to Root@yourdomain.tld. We divide the mapping structure above into the left-hand side lhs and the right-hand side RHS. RHS and LHS are abbreviations commonly used in mapping relationships. The following table illustrates the mapping relationship more clearly.
LHSRHS Postmaster:root
In the past, a colon (:) was used to ensure backtracking, and now postfix is usually not used in LHS. Local alias file It is a special file compiled with the newaliases command and not compiled with the usual postfix mapping command postmap. &http://www.aliyun.com/zixun/aggregation/37954.html ">NBSP;
Postfix Basic default installation, we create a text file for the mapping. We write the mapping to a text file and then use the Postmap command to convert the text file into a hash file. So postfix can quickly find this entry. For example, suppose we map our virtual mailboxes in a file/etc/postfix/virtual_mailboxes. The file structure is as follows:
Info@domain1.com Sigiri
Info@domain2.com Kala
You may have noticed that on the left hand side of the mapping file we did not use a colon (:). Then you need to run:
Postmap/etc/postfix/virtual_mailboxes
You can access the mapping by adding the following line to the Postfix configuration file:
Virtual_mailbox_maps = hash:/etc/postfix/virtual_mailboxes
During our installation, we will replace the mapping text file with the MySQL table. Because our goal is to be more flexible, more robust, more easily upgraded control data. A database table can contain two or more columns. Of course you need to tell postfix which column is LHS and which column is RHS. We can do this by building a configuration file like the following.
user = Postfix
Password = Yjinlqtubgnoe
hosts = 127.0.0.1
dbname = Postfix
Table = Mailbox
Select_field = Maildir
Where_field = Username
#additional_conditions = and active = ' 1 '
Suppose this configuration file is/etc/postfix/mysql_virtual_mailbox_maps.cf. You can now use this mapping in Postfix by using the following entries in the Main.cf file.
Virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
In the configuration file, user indicates the username that connects the MySQL database, password points out the password of user, dbname the name of the MySQL database, and table indicates the name of the tables in the MySQL database. Hosts indicate the name of the server running the MySQL database. Postfix uses this profile to indicate how to use the database to express the same mapping effect as the two-column mapping file mentioned above. The left hand side of the map is called the Where_field mapping of the right-hand side called the Select_field. In this example, we map maildir columns to username columns. Using this configuration, Postfix constructs an SQL query statement select Maildir from Postfix.mailbox where username= ' Doe ' Finds Maildir for a given username. The following table highlights this difference:
LHSRHS Where_fieldselect_field Usernamemaildir