网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

3-unit4postfix+mysql

##########postfix+mariadb#######
发送邮件

成都创新互联公司专注于上栗网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供上栗营销型网站建设,上栗网站制作、上栗网页设计、上栗网站官网定制、小程序设计服务,打造上栗网络公司原创品牌,更为您提供上栗网站排名全网营销落地服务。

准备工作
yum install httpd php php-MySQL mariadb-server -y

##配置mysql

config phpmyadmin
config mariadb
mysql_secure_installation
create db
create table
create usermessage
create dbuser
3-unit4 postfix+mysql

3-unit4 postfix+mysql

 ##添加数据库用户,并给其授权

3-unit4 postfix+mysql

3-unit4 postfix+mysql


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 


3-unit4 postfix+mysql
测试:
 postmap -q "cui@cui.com"mysql:/etc/postfix/mailuser.cf
cui@cui.com
 postmap -q "cui.com"mysql:/etc/postfix/maildomain.cf
cui.com
 postmap -q "cui@cui.com"mysql:/etc/postfix/mailbox.cf
/mnt/cui.com/cui/
3-unit4 postfix+mysql

####配置postfix
groupadd -g 123 vmail        ##添加用户组并指定gid为123

useradd -s /sbin/nologin -u 123 vmail -g 123    ##添加用户,并指定uid和gid为123

3-unit4 postfix+mysql
postconf -d |grep virtual   ##查询virtual
3-unit4 postfix+mysql

postconf -e "virtual_mailbox_base = /home/vmail"    ##设定虚拟用户的邮件目录
postconf -e "virtual_uid_maps = static:123"     ##虚拟用户建立文件的uid
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服务

3-unit4 postfix+mysql3-unit4 postfix+mysql

3-unit4 postfix+mysql

##测试:发送给cui@cui.com的邮件在/home/vmail/cui.com/cui/new/里找到

3-unit4 postfix+mysql

3-unit4 postfix+mysql

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

接收邮件
1.
yum install dovecot dovecot-mysql -y

##dovecot是一个开源的 IMAP 和 POP3 邮件服务器,支持 Linux,支持发送邮件

##dovecot-mysql  dovecot软件的插件,让此软件可以识别mysql
2.
vim /etc/dovecot/dovecot.conf
 24 protocols = imap pop3 lmtp      ##支持收件协议
 48 login_trusted_networks = 0.0.0.0/0  ##信任网络
 49 disable_plaintext_auth = no     ##开启明文认证
3-unit4 postfix+mysql
3-unit4 postfix+mysql

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

3-unit4 postfix+mysql

##生成dovecot读取mysql的配置
cp /usr/share/doc/dovecot-2.2.10/example-config/dovecot-sql.conf.ext/etc/dovecot/dovecot-sql.conf.ext
3-unit4 postfix+mysql

vim /etc/dovecot/dovecot-sql.conf.ext
 32 driver = mysql          ##数据库类型
 71 connect = host=localhost dbname=emailuser=postuser password=postuser   ##查询时用到的库,用户,密码
 78 default_pass_scheme = PLAIN     ##默认认证方式为明文
107 password_query = \          ##查询密码匹配
108   SELECT username, domain, password\
109   FROM emailuser WHERE username ='%u' AND domain = '%d'   
125 user_query = SELECT maildir, 123 AS uid, 123 AS gid FROM emailuser WHEREusername = '%u'    ##查询邮件内容
3-unit4 postfix+mysql
3-unit4 postfix+mysql
3-unit4 postfix+mysql
3-unit4 postfix+mysql


vim /etc/dovecot/conf.d/10-mail.conf
 30 mail_location =maildir:/home/vmail/%d%n    ##指定邮件位置
168 first_valid_uid = 123           ##邮件文件查询用户身份
175 first_valid_gid = 123
3-unit4 postfix+mysql
3-unit4 postfix+mysql
systemctl restart dovecot


测试:
[root@foundation62 ~]# 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 cui@cui.com
+OK
pass cui
+OK Logged in.
quit
+OK Logging out.
Connection closed by foreign host.
[root@foundation62 ~]#

3-unit4 postfix+mysql
 

3.空壳邮件

westos-mail主机为真机

qq-mail主机为空壳

在qq-mail上执行

vim   /etc/postfix/main.cf

myorigin = westos.com    ## 设置为真实的主机域名3-unit4 postfix+mysql

mydestination =          ##空壳邮件不接受邮件,所以不设置

3-unit4 postfix+mysql

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

3-unit4 postfix+mysql

##测试:空壳主机给本机root发送邮件但不接收,162主机接收邮件

3-unit4 postfix+mysql

3-unit4 postfix+mysql


网站栏目:3-unit4postfix+mysql
文章链接:http://bjjierui.cn/article/jcpdhi.html

其他资讯