postfix,dovecot

来源:互联网 发布:淘宝问大家回答删除 编辑:程序博客网 时间:2024/05/22 11:46


############################ postfix###########################

 

1.基本知识

postfix提供smtp协议用来投递邮件

默认端口25

/var/log/maillog ##服务日志

mail root@westos.com

Subject: hello

hello world

. #用"."来结束录入内容并发送

mailq ##查看邮件队列

postqueue -f ##重新处理邮件队列

 

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

 

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.service

systemctl stop firewalld

 

 

3.邮件别名

vim /etc/aliases

别名: 真名 ##邮件别名(单发)

别名: :include:filename ##邮件群发

 

 

vim filename  ##编写群发名单

user1

user2

 

postalias /etc/aliases   ##刷新名单文件

systemctl restart postfix

 

测试:

mail 别名

 

 

4.通过远程主机测试邮件服务

[kiosk@foundation0 Desktop]$ telnet 172.25.254.135 25  ##连接的ip及25端口

Trying 172.25.254.135...

Connected to 172.25.254.135.

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

250 2.1.5 Ok

data

354 End data with <CR><LF>.<CR><LF>

hj ,n j

hbn n

njk

.

 

 

5.邮件客户端的访问控制

 

1)限制客户端

mta上

postconf -e "smtpd_client_restrictions = check_client_access hash:/etc/postfix/access" ##将smtpd_client_restrictions = check_client_access hash:/etc/postfix/access加入/etc/postfix/main.cf中

 

vim /etc/postfix/access    ##编写被拒绝的文件

172.25.254.22 REJECT

 

postmap /etc/postfix/access ##加密文件

 

systemctl restart postfix

 

测试

如图一

 

 

2)限制用户发送

postconf -e "smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender"

 

vim /etc/postfix/sender       ##编写被拒绝的文件

student@westos.com REJECT

 

postmap  /etc/postfix/sender    ##加密文件

 

systemctl restart postfix

 

测试

如图二

 

 

3)限制用户接收

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

 

测试

如图四

 

 

##出站地址伪装

postconf -e "smtp_generic_maps = hash:/etc/postfix/generic"

 

vim /etc/postfix/generic         ##编写伪装的文件(匿名转换)

westos@westos.com   hello@ling.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"

 

vim /etc/postfix/virtual      ##编写伪装的文件(匿名转换)

虚拟名字 真实用户

hello@ling.com westos@westos.com

 

postmap /etc/postfix/virtual   ##加密文件

 

systectl restart postfix

 

 

测试:

mail hello@ling.com

 

 

############################# dovecot ####################################

 

1.协议

dovecot 用来提供收件协议

pop3 110

imap 143

imaps 993

pop3s 995

 

给定用户名称,用户密码,dovecot程序带我们去看这个用户的邮件文件

 

2.安装

yum install dovecot -y

systemctl start dovecot

 

3.配置

vim /etc/dovecot/dovecot.conf    ##主配置文件

24 protocols = imap pop3 lmtp      ##协议

48 login_trusted_networks = 0.0.0.0/0   ##允许所有人登录

49 disable_plaintext_auth = no         ##明文认证(否)

 

 

vim /etc/dovecot/conf.d/10-mail.conf     ##子策略文件

30 mail_location = mbox:~/mail:INBOX=/var/mail/%u   ##邮件的存放目录

 

systemctl restart dovecot

 

 

4.添加用户并设置密码

useradd westos

echo westos |passwd --stdin westos

 

su - westos

mkdir mail/.imap -p

touch mail/.imap/INBOX

 

 

5,测试:

mutt -f pop://westos@172.25.254.135

如图三

 

 

软件发送邮件:

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

 

如图五

 

如图六

 

原创粉丝点击