Get the App
SLTechnology News&Howtos  ›  Database  › 

Postfix+mysql

Shulou Source: shulou.com Published: 2022-06-01 19:39:12 09月11日 Update

1. Configure mysql

Before the experiment, the production should use the database and tables.

Add database users and authorize them

* vim / etc/postfix/mailuser.cf # # query user name

1 host = localhost # # Database host

2 user = postuser # # Login database user

3 password = 123 # # login password

4 dbname = email # # name of the postfix query library

5 table = emailuser # # name of the postfix query table

6 select_field = username # # fields for postfix query

7 where_field = username # # conditions for postfix query

* vim / etc/postfix/maildomain.cf # # Domain name query

1 host = localhost

2 user = postuser

3 password = 123

4 dbname = email

5 table = emailuser

6 select_field = domain

7 where_field = domain

Vim / etc/postfix/mailbox.cf

1 host = localhost

2 user = postuser

3 password = 123

4 dbname = email

5 table = emailuser

6 select_field = maildir

7 where_field = username

test

two。 Configure postfix

Groupadd-g 666 vmail # # add a user group and specify a gid of 666

Useradd-s / sbin/nologin-u 666 vmail-g 666 # # add users and specify uid and gid as 666

* postconf-e "virtual_mailbox_base = / home/vmail" # # set the virtual user mail directory

Postconf-e "virtual_uid_maps = static:666" # # specify the virtual user to create the file uid

Postconf-e "virtual_gid_maps = static:666" # # specify the virtual user to create the file gid

Postconf-e "virtual_alias_maps = mysql:/etc/postfix/mailuser.cf" # # specify MySQL lookup host

Postconf-e "virtual_mailbox_domains = mysql:/etc/postfix/maildomain.cf" # # specify the MySQL lookup domain name

Postconf-e "virtual_mailbox_maps = mysql:/etc/postfix/mailbox.cf" # # specify MySQL to find mailboxes

* systemctl restart postfix # # restart the postfix service

test

The email sent to linux@linux.com is found in / home/vmail/linux/new/

Tags: User query data database host name domain name file mail test login configuration field password condition query table user name user group directory mailbox Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Technology OPPO Reno Redmi MariaDB