#############################
1.限制远程用户vim /etc/postfix/access
ip REJECT
postconf -d |grep client ##查看使用参数
postfix map ##加密
postconf -e "smtpd_client_restrictions=check_client_access hash:/etc/postfix/access" ##写入文件
vim /etc/postfix/main.cf ##查看最后一行是否添加以上信息(注意颜色)
注:其实,可以在main.cf 文件中添加smtpd_client_restrictions=check_client_access hash:/etc/postfix/access
systemctl restart postfix.service验证:
在ip机上
1)telnet ip1 25
mail from:root@liu.com
2)vim /etc/postfix/main.cf ##删除最后一行
systemctl restart postfix.service
telnet ip1 25
mail from:root@liu.com
rcpt to:root@westos.com
data
.
########################
2.限制客户端指定用户发邮件vim /etc/postfix/xxx
student@liu.com REJECT
postmap xxx
postconf -e "smtpd_sender_restrictions=check_sender_access hash:/etc/postfix/xxx"
systemctl restart postfix.service
验证:
telnet ip1 25
mail from:student@liu.com
#######################
3.限制客户端指定用户收邮件vim /etc/postfix/xxxx
westos@liu.com REJECT
postmap xxxx
postconf -e "smtpd_recipient_restrictions=check_recipient_access hash:/etc/postfix/xxx"
systemctl restart postfix.service
########################
4.邮件本地用户服务端:
端口号
pop3 110
pop3S 995
imap 143
imaps 993
cat /etc/services |grep imap ##查看imap 的端口号
vim /etc/dovecot/dovecot.conf
24 protocols =imap pop3 lmpt
49 disable_plaintext_auth =no ##明文认证
50 login_trusted_networks =0.0.0.0/0
vim /etc/dovecot/conf.d/10-mail.conf
30 mail_location =mbox:~/mail:INBOX=/var/mail/%u
netstat -anltupe |grep dovecot
客户端:
telnet ip1 110
验证:
yum install mutt -y
mutt -f imap://username@ip1
#######################
5.邮件虚拟用户goupadd -g 888
useradd -g 888 -u 888 -s /sbin/nologin
在数据库中创建数据库mail,在mail库中创建表vuser,创建一些信息
例如:admin@westos.org 123 westos.org westos.org/admin/
username password domain maildir
在数据库中创建一个用户 postfix 并授权
编辑文件
vim /etc/postfix/mysql-users.cf
hosts=localhost
user=postfix
password=postfix
dbname =mail
table= vuser
select_field=username
where_field=username
vim /etc/postfix/mysql-domain.cf
hosts=localhost
user=postfix
password=postfix
dbname =mail
table= vuser
select_field=domain
where_field=domain
vim /etc/postfix/mysql-users.cf
hosts=localhost
user=postfix
password=postfix
dbname =mail
table= vuser
select_field=maildir
where_field=username
postmap -q "admin@westos.org"mysql:/etc/postfix/mysql-users.cf
postmap -q "westos.org"mysql:/etc/postfix/mysql-domain.cf
postmap -q "admin@westos.org"mysql:/etc/postfix/mysql-maildir.cf
将数据写入配置文件
postconf -d |grep map
postconf -e "virtual_uid_maps=static:888"
postconf -e "virtual_gid_maps=static:888"
postconf -e "virtual_mailbox_base =/home/vmail"
postconf -e "virtual_alias_maps=mysql:/etc/postfix/mysql-users.cf"
postconf -e "virtual_virtual_mailbox_domains=mysql:/etc/postfix/mysql-domain.cf"
postconf -e "virtual_mailbox_maps=mysql:/etc/postfix/mysql-maildir.cf"
验证:mail admin@westos.org
##########################
6.数据库和邮箱连接yum install dovecot-mysql -y
cp -p /usr/share/doc/dovecot-2.2.10/example-config/dovecot-sql.conf.ext /etc/dovecot
vim /etc/dovecot/dovecot-sql.conf.ext
32 driver=mysql
70 connect=host=localhost dbname=email user=postfix password=postfix
106 password_query = \
107 SELECT username,domain,password \
108 FROM vuser WHERE username='%u' AND domain ='%d'
124 user_query=SELECT maildir,888 AS uid,888 AS gid FROM vuser WHERE username='%u'
vim 10-mail.conf
30 mail_location=maildir:/home/vmail/%d/%n
168 first_valid_uid=888
175 first_valid_gid=888
vim 10-auth.conf
122 !include auth-system.conf.ext
123 !include auth-sql.conf.ext
chmod +x /run/dovecot/
验证:
telnet ip1 110
user admin@westos/org
pass 123
##########################
7.空壳邮件空壳端:
vim /etc/resolv.conf
nameserver ip
vim /etc/named.rfc1912.zones
zone "westos,org" IN{
type master;
file "westos.org.zone";
allow-update{none;};
};
cp -p /var/named/westos.com.zone /var/named/westos.org.zone
vim /var/named/westos/org.zone
%s/com/org/g
vim /etc/postfix/main.cf
75 myhostname=主机名
83 mydomain =主机域名
98 myorigin= westo.org
113 inet_interfaces=all
140 local_transport =error :local delivery disabled
164 mydestination=
313 relayhost=ip
systemctl stop firewalld
服务器:
vim /etc/postfix/main.cf
264 mynetworks=ip
验证:
rm -fr /home/vmail/*
mail admin@westos.org
#######################