3-UNIT4 Postfix+mysql

Source: Internet
Author: User
Tags auth imap dovecot vmail

######### #postfix +mariadb#######
Send mail

Preparatory work
Yum install httpd php php-mysql mariadb-server-y

# # config MySQL

Config phpMyAdmin
Config mariadb
Mysql_secure_installation
Create db
CREATE table
Create Usermessage
Create Dbuser
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/97/52/wKiom1ktUU_RTUddAAEJlAkhouI608.png "title=" 234520170530185409.png "style=" Float:none; "alt=" Wkiom1ktuu_rtuddaaejlakhoui608.png "/>


650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/97/53/wKioL1ktUVGwzkvKAAHhyh6parE615.png "title=" 234520170530185603.png "style=" Float:none; "alt=" Wkiol1ktuvgwzkvkaahhyh6pare615.png "/>

# #添加数据库用户, and give it permission

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/97/52/wKiom1ktUVLzIsPzAAG7HYvbSVU418.png "title=" 234520170530185659.png "style=" Float:none; "alt=" Wkiom1ktuvlzispzaag7hyvbsvu418.png "/>

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/97/53/wKioL1ktUVKzIRqqAAGSX3_cAVY627.png "title=" 234520170530185707.png "style=" Float:none; "alt=" Wkiol1ktuvkzirqqaagsx3_cavy627.png "/>



1.
VIM/ETC/POSTFIX/MAILUSER.CF # #用户名称查询
host = localhost # #数据库所在主机
user = Postuser # #登陆数据库的用户
Password = postuser # #登陆数据库的用户密码
dbname = email # #postfix要查询的库的名称
Table = emailtable # #postfix要查询的表的名称
Select_field = Username # #postfix要查询的字段
Where_field = Username # #用户给定postfix的查询条件

VIM/ETC/POSTFIX/MAILDOMAIN.CF # #用户域名查询
host = localhost
user = Postuser
Password = Postuser
dbname = Email
Table = emailtable
Select_field = Domain
Where_field = Domain

VIM/ETC/POSTFIX/MAILBOX.CF # #用户邮箱位置查询
host = localhost
user = Postuser
Password = Postuser
dbname = Email
Table = emailtable
Select_field = Maildir
Where_field = Username


650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/97/53/wKioL1ktUVOiN1oLAAHEdrbwPC8399.png "title=" 234520170530185735.png "style=" Float:none; "alt=" Wkiol1ktuvoin1olaahedrbwpc8399.png "/>
Test:
Postmap-q "[email protected]" MYSQL:/ETC/POSTFIX/MAILUSER.CF
[Email protected]
Postmap-q "Cui.com" mysql:/etc/postfix/maildomain.cf
Cui.com
Postmap-q "[email protected]" MYSQL:/ETC/POSTFIX/MAILBOX.CF
/mnt/cui.com/cui/
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/97/52/wKiom1ktUVPjLF_-AAErAPceGVQ908.png "style=" float : none; "title=" 234520170530185724.png "alt=" Wkiom1ktuvpjlf_-aaerapcegvq908.png "/>

# # #配置postfix
Groupadd-g 123 Vmail # # Add user group and specify GID as 123

Useradd-s/sbin/nologin-u 123 vmail-g 123 # #添加用户, and specify UID and GID for 123

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/97/52/wKiom1ktUVTzGO9sAAEXyHBo7Iw480.png "title=" 234520170530185754.png "style=" Float:none; "alt=" Wkiom1ktuvtzgo9saaexyhbo7iw480.png "/>
postconf-d |grep Virtual # #查询virtual
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/97/52/wKiom1ktUVXiRV0-AANF-EzYu14100.png "style=" float : none; "title=" 234520170530185807.png "alt=" Wkiom1ktuvxirv0-aanf-ezyu14100.png "/>

postconf-e "virtual_mailbox_base =/home/ Vmail "    # #设定虚拟用户的邮件目录
postconf-e" virtual_uid_maps = static:123 "     # # Virtual user establishes UID for file
postconf-e "virtual_gid_maps = static:123"      # #虚拟用户建立文件的gid
Postconf-e " Virtual_alias_maps = mysql:/etc/postfix/mailuser.cf "   # #指定mysql查找主机
Postconf-e" Virtual_mailbox_ Domains =mysql:/etc/postfix/maildomain.cf "    # #指定mysql查找域名
postconf-e" virtual_mailbox_maps = MYSQL:/ETC/POSTFIX/MAILBOX.CF "  # #指定mysql查找邮箱

Systemctl Restart postfix         # #重启postfix服务

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/97/54/ Wkiol1ktvssx5f8aaahpbzvxh9a469.png "title=" 234520170530191844.png "alt=" Wkiol1ktvssx5f8aaahpbzvxh9a469.png "/> 650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/97/52/wKiom1ktUVaSU389AAG_42OU_mQ693.png "style=" float : none; "title=" 234520170530185833.png "alt=" Wkiom1ktuvasu389aag_42ou_mq693.png "/>

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/97/53/wKioL1ktUVei6EvrAAGDbuSobks940.png "style=" float : none; "title=" 234520170530185843.png "alt=" Wkiol1ktuvei6evraagdbusobks940.png "/>

# #测试: Mail sent to [email protected] found in/home/vmail/cui.com/cui/new/

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/97/52/wKiom1ktUVfj75ICAAEWmux_AJk733.png "title=" 234520170530185857.png "style=" Float:none; "alt=" Wkiom1ktuvfj75icaaewmux_ajk733.png "/>

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/97/53/wKioL1ktUViBu6rTAAIPckmkbVw464.png "title=" 234520170530185910.png "style=" Float:none; "alt=" Wkiol1ktuvibu6rtaaipckmkbvw464.png "/>



########### #dovecot +mysql############

Receive mail
1.
Yum Install Dovecot dovecot-mysql-y

# #dovecot is an open source IMAP and POP3 mail server that supports Linux and supports sending mail

# #dovecot-mysql dovecot Software plugin that allows this software to recognize MySQL
2.
Vim/etc/dovecot/dovecot.conf
protocols = IMAP POP3 LMTP # #支持收件协议
Login_trusted_networks = 0.0.0.0/0 # #信任网络
Disable_plaintext_auth = no # #开启明文认证
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/97/53/wKioL1ktUVngXlrzAAB9jBz42iQ302.png "title=" 234520170530185931.png "style=" Float:none; "alt=" Wkiol1ktuvngxlrzaab9jbz42iq302.png "/>
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/97/52/wKiom1ktUVnis1_gAADIcA0QaJM242.png "title=" 234520170530185937.png "style=" Float:none; "alt=" Wkiom1ktuvnis1_gaadica0qajm242.png "/>

Vim/etc/dovecot/conf.d/10-auth.conf
123!include Auth-sql.conf.ext # #开启mysql的认证方式

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/97/54/wKioL1ktVgPTX_rdAABrXPNWGBQ083.png "title=" 234520170530190034.png "style=" Float:none; "alt=" Wkiol1ktvgptx_rdaabrxpnwgbq083.png "/>

# #生成dovecot读取mysql的配置
Cp/usr/share/doc/dovecot-2.2.10/example-config/dovecot-sql.conf.ext/etc/dovecot/dovecot-sql.conf.ext
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/97/54/wKioL1ktVgTi5szJAAEjsT0MBLo003.png "title=" 234520170530190101.png "style=" Float:none; "alt=" Wkiol1ktvgti5szjaaejst0mblo003.png "/>

Vim/etc/dovecot/dovecot-sql.conf.ext
Driver = mysql # #数据库类型
Connect = host=localhost dbname=emailuser=postuser Password=postuser # #查询时用到的库, user, password
Default_pass_scheme = PLAIN # #默认认证方式为明文
107 password_query = \ # #查询密码匹配
108 SELECT username, domain, password\
109 from Emailuser WHERE username = '%u ' and domain = '%d '
User_query = SELECT Maildir, 123 as UID, 123 as GID from emailuser whereusername = '%u ' # #查询邮件内容
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/97/52/wKiom1ktVgOy1SDoAAA14eq4inY632.png "title=" 234520170530190027.png "style=" Float:none; "alt=" Wkiom1ktvgoy1sdoaaa14eq4iny632.png "/>
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/97/54/wKioL1ktVgPxbGa9AADN_03oPCc983.png "title=" 234520170530190020.png "style=" Float:none; "alt=" Wkiol1ktvgpxbga9aadn_03opcc983.png "/>
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/97/52/wKiom1ktVgLA_p3MAAC9m-YUyQE779.png "title=" 234520170530190005.png "style=" Float:none; "alt=" Wkiom1ktvgla_p3maac9m-yuyqe779.png "/>
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/97/52/wKiom1ktVgLhrBzWAACf8LUJj9k627.png "title=" 234520170530190012.png "style=" Float:none; "alt=" Wkiom1ktvglhrbzwaacf8lujj9k627.png "/>


Vim/etc/dovecot/conf.d/10-mail.conf
Mail_location =maildir:/home/vmail/%d%n # #指定邮件位置
168 first_valid_uid = 123 # #邮件文件查询用户身份
175 First_valid_gid = 123
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/97/53/wKioL1ktUVqjPmNCAABqylOYSUg547.png "title=" 234520170530185946.png "style=" Float:none; "alt=" Wkiol1ktuvqjpmncaabqyloysug547.png "/>
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/97/54/wKioL1ktVt_zZPtIAAEYINvRvOw873.png "title=" 234520170530192554.png "alt=" Wkiol1ktvt_zzptiaaeyinvrvow873.png "/>
Systemctl Restart Dovecot


Test:
[[Email protected] ~]# Telnet 172.25.254.150 110
Trying 172.25.254.150 ...
Connected to 172.25.254.150.
Escape character is ' ^] '.
+ok [xclient] dovecot ready.
User [email protected]
+ok
Pass Cui
+ok logged in.
Quit
+ok Logging out.
Connection closed by foreign host.
[Email protected] ~]#

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/97/52/wKiom1ktUViz_gU2AAEQu8EmpRw688.png "title=" 234520170530185924.png "style=" Float:none; "alt=" Wkiom1ktuviz_gu2aaequ8emprw688.png "/>

3. Empty Shell Mail

Westos-mail host for the real machine

Qq-mail Host is empty shell

Execute on the Qq-mail

Vim/etc/postfix/main.cf

myorigin = westos.com # # Set to the real host domain name 650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/97/52/ Wkiom1ktvgsz8yk9aabthmivqlg209.png "title=" 234520170530190111.png "style=" Float:none; "alt=" Wkiom1ktvgsz8yk9aabthmivqlg209.png "/>

mydestination = # #空壳邮件不接受邮件, so do not set

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/97/52/wKiom1ktVgXy4G5WAAB4IzIvVCY552.png "title=" 234520170530190117.png "style=" Float:none; "alt=" Wkiom1ktvgxy4g5waab4izivvcy552.png "/>

Relayhost = 172.25.254.162 # #接替的真实主机的IP

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/97/54/wKioL1ktVgXQzIdMAAB_LPgi00s405.png "title=" 234520170530190123.png "style=" Float:none; "alt=" Wkiol1ktvgxqzidmaab_lpgi00s405.png "/>

# #测试: empty shell host sends mail to native root but does not receive, 162 host receives mail

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/97/54/wKioL1ktVgaA-jlEAAGzSKfi8rE529.png "title=" 234520170530190148.png "style=" Float:none; "alt=" Wkiol1ktvgaa-jleaagzskfi8re529.png "/>

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/97/52/wKiom1ktVgbiZg56AAHX6GpI-MM597.png "title=" 234520170530190203.png "style=" Float:none; "alt=" Wkiom1ktvgbizg56aahx6gpi-mm597.png "/>

3-UNIT4 Postfix+mysql

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.