postfix

1.
yum install bind -y
vim /etc/named.conf
注释掉11,12,17行 32行yes改为no
vim /etc/named.rfc1912.zones
改westos.com qq.com和他们的配置文件
cd /var/named
cp -p named.localhost westos.com.zone
vim westos.com.zone
cp -p westos.com.zone qq.com.zone
vim qq.westos.zone
systemclt restart named
systemctl stop firewalld
postfix提供smtp协议用来投递邮件
默认端口25
/var/log/maillog   #服务日志
mail root@westos.com
Subject: hello
.                #用“."来结束录入内容并发送
mailq            #查看邮件队列
postqueue -f     #重新处理邮件队列
postsuper -d *    #删除错的邮件

默认情况下邮件端口只在127.0.0.1上开启

systemctl  stop  firewalld

systemctl   disable  firewalld


2.配置
vim /etc/postfix/main.cf
76 myhostname = westos-mail.westos.com  #指定mta的主机名称
83 mydomain = westos.com                #指定mta的域名
99 myorigin = westos.com                #指定邮件来源结尾(@后面的字符内容)
116 inet_interfaces = all               #25端口开启的网络接口

164 mydestination = $myhostname, $mydomain, localhost #接受邮件结尾字符的指定

systemctl  restart  postfix


3.邮件别名
[root@qq-mail ~] #vim /etc/aliases
别名:真名            ##邮件别名
别名:         :include:filename    #邮件群发

vim /filename
user1
user2

postalias /etc/aliases
systemctl restart postfix
mail 别名

远程发邮件
ot@foundation18 Desktop]# telnet 172.25.254.218 25
Trying 172.25.254.218...
Connected to 172.25.254.218.
Escape character is '^]'.
220 westos-mail.westos.com ESMTP Postfix
ehlo hello
250-westos-mail.westos.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:root@westos.com
250 2.1.0 Ok
rcpt to:root@qq.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
dfadad
hello
chen
.
250 2.0.0 Ok: queued as 9C04F17E86C
quit

Connection closed by foreign host.


5.邮件客户端的访问控制
在mta上
postconf -e "smtpd_client_restrictions = check_client_access hash:/etc/postfix/access"
vim /etc/postfix/access
172.25.254.x  REJECT
postmap /etc/postfix/access
systmctl restart postfix
测试
[root@foundation70 Desktop]# telnet 172.25.254.218 25
Trying 172.25.254.218...
Connected to 172.25.254.218.
Escape character is '^]'.
220 westos-mail.westos.com ESMTP Postfix
mail from:root@westos.com
250 2.1.0 Ok
rcpt to:root@qq.com
554 5.7.1 <unknown[172.25.254.70]>: Client host rejected: Access denied


限制用户发送
postconf -e "smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender"

vim /etc/postfix/sender
student@westos.com   REJECT
systemctl restart postfix
测试
[kiosk@foundation18 Desktop]$ telnet 172.25.254.218 25
Trying 172.25.254.218...
Connected to 172.25.254.218.
Escape character is '^]'.
220 westos-mail.westos.com ESMTP Postfix
mail from:student@westos.com
250 2.1.0 Ok
rcpt to:root@westos.com
554 5.7.1 <student@westos.com>: Sender address rejected: Access denied


限制用户接收
postconf -e "smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recip

vim /etc/postfix/recip
westos@westos.com REJECT

postmap /etc/postfix/recip

systemctl restart postfix

测试
[kiosk@foundation18 Desktop]$ telnet 172.25.254.218 25
Trying 172.25.254.218...
Connected to 172.25.254.218.
Escape character is '^]'.
220 westos-mail.westos.com ESMTP Postfix
mail from:westos@westos.com
250 2.1.0 Ok
rcpt to:root@westos.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
fdsfa
dsadf
.
250 2.0.0 Ok: queued as 537B517E873
qiut
502 5.5.2 Error: command not recognized
mail from:root@westos.com
250 2.1.0 Ok
rcpt to:westos@westos.com
554 5.7.1 <westos@westos.com>: Recipient address rejected: Access denied


##出站地址伪装
postconf -e "smtp_generic_maps = hash:/etc/postfix/generic"

vim /etc/postfix/generic
westos@westos.com    hello@chen.com

postmap /etc/postfix/generic

systemctl restart postfix
测试
su westos

mail root@qq.com


入站地址转换
dns mx解析要先做好

postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual"
/etc/postfix/virtual
虚拟用户          真实用户
hello@chen.com    westos@westos.com
postmap /etc/postfix/virtual
systemctl restart postfix
测试
mail hello@chen.com

dovecot
1.
dovecot 用来提供收件协议
pop3    110
imap    143
imaps    993
pops     995

给定用户名称,用户密码,dovecot程序带我们去看这个用户的邮件文件
vim /etc/dovecet/dovecet.conf      #主配置文件
24   protocols = imap pop3 lmtp  #去掉注释
48   login_trusted_network = 0.0.0.0/0
49   disable_plaintext_auth = no
vim /etc/dovecot/conf.d/10-mail.con  #子配置文件
30   mail_location = mbox:~/mail:INBOX=/var/mail/%u

systemctl restart dovecot.service

passwd westos

su westos
[westos@westos-mail ~]$ mkidr mail/.imp/ -p
[westso@westos-mail ~ ]$ touch mail/.imap/INBOX ##单个用户生效
在root下
mkdir /etc/skel/mail/.imap -p
touch /etc/skel/mail/.imap/INBOX  ##自动生效
测试
在root用户 yum install mutt -y
mutt -f pop://westos@172.25.254.218


下载 thunderbird-31.2.0-1.el7.x86_64.rpm

rpm -ivh  thunderbird-31.2.0-1.el7.x86_64.rpm

打开 thunderbird


postfix+mariadb   

准备工作

yum install httpd php php-mysql mariadb-servr -y  进行相关配置



1.vim /etc/postfix/mailuser.cf  #用户名称查询
hosts = localhost               #数据库所在的主机
user = postuser                 #登陆数据库的用户
password = postuser             #登陆数据库的密码
dbname = email                  #postfix要查询的名称
table = emailuser               #postfix要查询的表的名称
select_field = username         #postfix要查询的子段
where_field = username          #用户给定postfix的查询条件

vim /etc/postfix/maildomain.cf      #用户域名查询
hosts = localhost
user = postuser
password = postuser
dbname = email
table = emailuser
select_field = domain
where_field = domain

vim /etc/postfix/mailbox.cf         #用户邮箱位置查询
hosts = localhost
user = postuser
password = postuser
dbname = email
table = emailuser
select_field = maildir
where_field = username

postmap -q "lee@lee.com" mysql:/etc/postfix/mailuser.cf
lee2@lee.com
postmap -q "lee.com" mysql:/etc/postfix/maildomain.cf
lee.com
postmap -q "lee@lee.com" mysql:/etc/postfix/mailbox.cf
/mnt/lee.com/lee

配置postfix
groupadd -g 666 vmail
useradd -s /sbin/nologin -u 666 vmail -g 666
postconf -e "virtual_mailbox_base = /home/vmail"
postconf -e "virtual_uid_maps = static:666"
postconf -e "virtual_gid_maps = static :666"
postconf -e "virtual_alias_maps = mysql:/etc/postfix/mailuser.cf"
postconf -e "virtual_mailbox_domains = mysql:/etc/postfix/maildomain.cf"
postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mailbox.cf"

systemctl restart postfix



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值