3-unit4 postfix+mysql
admin
2023-05-24 00:03:18
0

##########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+mysql
3-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

相关内容

热门资讯

伊朗高官:美试图阻挠伊朗阿曼就... 据伊朗方面4日消息,一名伊朗高级官员说,美国政府试图阻挠伊朗与阿曼之间关于霍尔木兹海峡管理的持续谈判...
铠侠与闪迪发布第十代332层Q... IT之家 8 月 4 日消息,铠侠株式会社今天宣布与闪迪公司共同推出下一代四层单元(QLC)3D 闪...
官方通报卫生巾疑现虫卵:对涉事... 8月4日晚,广西桂林市七星区市场监督管理局发布情况通报:4日,网络上关于“购买的卫生巾疑现虫卵”的信...
奖励一颗小行星命名!中国科学家... 中国科学家又有喜讯了。 综合中国气象报社、科技日报消息,当地时间8月3日,在意大利佛罗伦萨举办的第4...
全球最大通信卫星刚上天,休斯为... 卫星互联网商业模式观察 全球最大通信卫星刚上天, 休斯为什么还是被星链逼到破产? 作者 | 老谭 ...
中国版「生物DeepSeek」... 新智元报道 DeepSeek-V4-Flash正式版刚炸翻全球通用大模型圈,中国生命科学版Deep...
汽车回血,AI烧钱,特斯拉迎来... 文|高恒说 特斯拉开始把造车产线让给机器人。 2026年第二季度,特斯拉拆除了弗里蒙特工厂原有的M...
鸿蒙智行承认投诉“竹知了”视频... 针对“竹知了”玩具相关舆情,鸿蒙智行于8月4日晚发布企业声明,介绍了投诉“竹知了”视频相关情况,也表...
抢劫杀人犯死刑改死缓被害人家属... 澎湃新闻记者 熊强云南宣威市乐丰乡1999年“山村小卖部抢劫杀人案”被害人家属申诉迎来新进展:家属徐...
乘客投诉绕路遭出租车司机持铁棍... 8月4日晚,太原市公安局小店分局官方微博通报:7月20日凌晨2时许,我局接到群众报警,小店区体育路许...