Linux之邮件服务

17 篇文章 0 订阅
2 篇文章 0 订阅

#############################

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
#######################



 































评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值