Recently, I was working on a project to design a mailbox for users.
The specific process is as follows: when you create a new user for the system, you can also create an IMAP mailbox for the user.
The IMAP server uses Cyrus.
SMTP server uses postfox
Postfox received the email instead of directly sending it to the local email directory of Cyrus (it seems that the maildir of Cyrus is not in the standard format ), instead, it is passed to the local directory of Cyrus through the LMTP service of Cyrus. CF has the following settings
Mailbox_transport = LMTP: Unix:/var/spool/Postfix/socket/LMTP
Fallback_transport = LMTP: Unix:/var/spool/Postfix/socket/LMTP
The problem now is that the customer has a need because the user is using an automatically generated User Name (16 random characters) when creating an IMAP mailbox for the user, which is inconvenient to use, therefore, the customer requires that the user can change the user name in the mailbox.
After investigation, the logon username of Cyrus is the same as the directory name of maildir. Because Cyrus uses SSL dB authentication, it is very good to change the logon username, however, Cyrus cannot directly change the maildir directory. The common practice is to create a new mailbox, copy all the directories and emails in the old mailbox to the new mailbox, and then delete the old mailbox, this operation is difficult to complete.
Therefore, I gave up my intention to change the user's mailbox.
Another new approach is to change the Postfix settings and create a virtual email table in the database. You can send emails to the real mailbox through the Virtual email table.
For example, there is a user mailbox for the asdfasdfasdfasdfasdf@example.com, if the user to send mail, you must send to this address, if the user wants to change their mailbox to flyforlove@example.com, then you can forward the mail sent to flyforlove@example.com to asdfasdfasdfasdfasdf@example.com.
The main settings are as follows:
Set the main. cf file of Postfix (using the ipvs database)
Virtual_alias_maps = pgsql:/etc/Postfix/pgsql-virtual-alias.cf
Setting of file/etc/Postfix/pgsql-virtual-alias.cf
Hosts = dbhost
User = dbuserid
Dbname = dbname
Table = "t_table_name"
Select_field = "real_name"
Where_field = "alias_name"
# Added query Conditions
Additional_conditions = and "delete_flag" = false
Because Cyrus itself does not support logon usernames and ing of their email boxes, it is impossible to log on with flyforlove. You can view the emails of asdfasdfasdfasdfasdf.
Fortunately, the system does not run and the user logs on to the IMAP server using the client, so this problem is not a problem in the current system.
However, we still want to implement the Cyrus user name and arbitrary mapping of their mail boxes.