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 [email protected]
Subject: hello
.                #用“."来结束录入内容并发送
mailq            #查看邮件队列
postqueue -f     #重新处理邮件队列
postsuper -d *    #删除错的邮件

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

systemctl  stop  firewalld

systemctl   disable  firewalld

postfix
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

postfix

3.邮件别名
[[email protected] ~] #vim /etc/aliases
别名:真名            ##邮件别名
别名:         :include:filename    #邮件群发

vim /filename
user1
user2

postalias /etc/aliases
systemctl restart postfix
mail 别名
postfixpostfix
远程发邮件
[email protected] 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:[email protected]
250 2.1.0 Ok
rcpt to:[email protected]
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.

postfixpostfix

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
测试
[[email protected] 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:[email protected]
250 2.1.0 Ok
rcpt to:[email protected]
554 5.7.1 <unknown[172.25.254.70]>: Client host rejected: Access denied
postfix

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

vim /etc/postfix/sender
[email protected]   REJECT
systemctl restart postfix
测试
[[email protected] 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:[email protected]
250 2.1.0 Ok
rcpt to:[email protected]
554 5.7.1 <[email protected]>: Sender address rejected: Access denied
postfix

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

vim /etc/postfix/recip
[email protected] REJECT

postmap /etc/postfix/recip

systemctl restart postfix

测试
[[email protected] 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:[email protected]
250 2.1.0 Ok
rcpt to:[email protected]
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:[email protected]
250 2.1.0 Ok
rcpt to:[email protected]
554 5.7.1 <[email protected]>: Recipient address rejected: Access denied
postfix

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

vim /etc/postfix/generic
[email protected]    [email protected]

postmap /etc/postfix/generic

systemctl restart postfix
测试
su westos

mail [email protected]

postfix

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

postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual"
/etc/postfix/virtual
虚拟用户          真实用户
[email protected]    [email protected]
postmap /etc/postfix/virtual
systemctl restart postfix
测试
mail [email protected]
postfixpostfix
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
[[email protected] ~]$ mkidr mail/.imp/ -p
[[email protected] ~ ]$ 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://[email protected]

postfix


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

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

打开 thunderbird

postfix

postfix+mariadb   

准备工作

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

postfix

postfix
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 "[email protected]" mysql:/etc/postfix/mailuser.cf
[email protected]
postmap -q "lee.com" mysql:/etc/postfix/maildomain.cf
lee.com
postmap -q "[email protected]" 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

postfixpostfix