{**邮件的发送与接收**}
[拒绝某ip发送]
useradd westos
passwd westos
[[email protected] ~]# cd /etc/postfix/
[[email protected] postfix]# ls
access generic main.cf relocated virtual
canonical header_checks master.cf transport
[[email protected] postfix]# vim access
172.25.254.149 REJECT 最后一行添加要禁止的
[[email protected] postfix]# postmap access 执行完会出现新的db文件
[[email protected] postfix]# ls
access canonical header_checks master.cf transport
access.db generic main.cf relocated virtual
[[email protected] postfix]# postconf -d | grep client
postconf -e "smtpd_client_restrictions = check_client_access hash:/etc/postfix/access"
systemctl restart postfix.service 重启服务
测试
[[email protected] postfix]# telnet 172.25.254.249 25
Trying 172.25.254.249...
Connected to 172.25.254.249.
Escape character is ‘^]‘.
220 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.249]>: Client host rejected: ACCESS(5)
(ip被拒绝发送)
[拒绝某一用户发送]
vim sender (文件名任意)
[email protected] REJECT 拒绝用户的全称
postmap sender 刷新(必须要做)
postconf -e "smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender"
systemctl restart postfix.service 重启服务
测试
[[email protected] postfix]# telnet 172.25.254.249 25Trying 172.25.254.249...
Connected to 172.25.254.249.
Escape character is ‘^]‘.
220 westos.com ESMTP Postfix
mail from:[email protected]
250 2.1.0 Ok
rcpt to:root:westos.com
554 5.7.1 <[email protected]>: Sender address rejected: Access denied (该用户被拒绝发送)
[拒绝某一用户接收文件]
vim recip
[email protected] REJECT 拒绝用户的全称
postmap recip 刷新
postconf -e "smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recip"
systemctl restart postfix.service 重启服务
测试
[[email protected] postfix]# telnet 172.25.254.249 25
Trying 172.25.254.249...
Connected to 172.25.254.249.
Escape character is ‘^]‘.
220 westos.com ESMTP Postfix
mail from:[email protected]
250 2.1.0 Ok
rcpt to:[email protected]
554 5.7.1 <[email protected]>: Recipient address rejected: Access denied (该用户被拒绝接收)
[远程访问邮箱]
主机
yum install dovecot -y 安装服务
(所用端口 imap 143 pop3 110 imaps 993 pop3 995)
cd /etc/dovecot
vim dovecot.conf
24 protocols = imap pop3 lmtp 开放协议
49 disable_plaintext_auth = no 允许不加密
cd conf.d
vim 10-mail.conf
mail_location = mbox:~/mail:INBOX=/var/mail/%u 邮件存放地点
systemctl start dovecot 开启服务
su - student 切换至用户
mkdir /home/student/mail/.imap -p 建立需要的目录和文件
touch /home/student/mail/.imap/INBOX
client机
yum install mutt -y 安装服务
muut -f pop://[email protected]249
图形界面
主机
vim /etc/dovect/dovecot.conf 修改配置文件
48 login_trusted_networks = 0.0.0.0/0
systemctl restart dovect 重启服务
client机
lftp 172.25.254.250 -X
tar jxf thunderbird-31.4.0.tar.bz2 解压
cd thunderbird/
./thunderbird 执行文件(安装依赖文件)
yum whatprovides /lib/ld-linux.so.2
yum install glibc-2.17-55.el7.i686 -y
./thunderbird
yum whatprovides libstdc++.so.6
yum install libstdc++-4.8.2-16.el7.i686 -y
./thunderbird
yum whatprovides libXrender.so.1
yum install libXrender-0.9.8-2.1.el7.i686 -y
./thunderbird
yum whatprovides libasound.so.2
yum install alsa-lib-1.0.27.2-3.el7.i686 -y
./thunderbird
yum whatprovides libdbus-glib-1.so.2
yum install dbus-glib-0.100-7.el7.i686 -y
./thunderbird
yum whatprovides libgtk-x11-2.0.so.0
yum install gtk2-2.24.22-5.el7.i686 -y
./thunderbird
yum whatprovides libXt.so.6
yum install libXt-1.1.4-6.1.el7.i686 -y
./thunderbird 运行
[虚拟账户的邮件管理]
配置数据库
yum install mariadb-server.x86_64 安装服务
yum install httpd php php-mysql -y
cd /var/www/html
fltp 172.25.254.250 **下载安装包
tar jxf phpMyAdmin-3.4.0-all-languages.tar.bz2 **解压
mv phpMyAdmin-3.4.0-all-languages/ myadmin **重命名
cd myadmin/
cp config.sample.inc.php config.inc.php
vim config.inc.php 修改文件
$cfg[‘blowfish_secret‘] = ‘westos‘; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
systemctl start mariadb
systemctl start httpd
mysql_secure_installation 数据库安全设置
systemctl restart mariadb.service 重启服务
mysql -u root -pwetsos 进入数据库
MariaDB [(none)]> CREATE USER [email protected] identified by ‘postfix‘ ;
Query OK, 0 rows affected (0.00 sec) 创建用户postfx
MariaDB [(none)]> GRANT INSERT,UPDATE,SELECT on email.* to [email protected] ;
Query OK, 0 rows affected (0.00 sec) 赋予权限
vim mysql-users.cf
host = localhost
user = postfix
password = postfix
dbname = email
table = muser
select_field = username
where_field = username
vim mysql-domain.cf
host = localhost
user = postfix
password = postfix
dbname = email
table = muser
select_field = domain
where_field = domain
vim mysql-maildir.cf
host = localhost
user = postfix
password = postfix
dbname = email
table = muser
select_field = maildir
where_field = username
groupadd -g 111 vmail 创建用户组
useradd -g 111 -u 111 -s /sbin/nologin vmail 该用户不能用shell(非交互式)
postconf -e "virtual_gid_maps = static:111"
postconf -e "virtual_uid_maps = static:111"
postconf -e "virtual_mailbox_base = /home/vmail"
postconf -e "virtual_alias_maps = mysql:/etc/postfix/mysql-users.cf"
postconf -e "virtual_mailbox_domains = mysql:/etc/postfix/mysql-domain.cf"
postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mysql-maildir.cf"
systemctl restart postfix.service
cd /etc/dovecot/c.conf
vim 10-auth.conf
122 !include auth-system.conf.ext
123 !include auth-sql.conf.ext
124 #!include auth-ldap.conf.ext
125 #!include auth-passwdfile.conf.ext
126 #!include auth-checkpassword.conf.ext
127 #!include auth-vpopmail.conf.ext
128 #!include auth-static.conf.ext
vim 10-mail.conf
30 mail_location =maildir:/home/vmail/%d/%n
169 first_valid_uid = 111
176 first_valid_gid = 111
cd /usr/share/doc/dovecot-2.2.10/
cd example-config/
cp dovecot-sql.conf.ext /etc/dovecot/
vim dovecot-sql.conf.ext
31 # Database driver: mysql, pgsql, sqlite
32 driver = mysql
71 connect = host=localhost dbname=mail user=postfix password=postfix
73 # Default password scheme.
75 # List of supported schemes is in
76 # http://wiki2.dovecot.org/Authentication/PasswordSchemes
78 default_pass_scheme = PLAIN
107 password_query = \
108 SELECT username, domain, password \
109 FROM users WHERE username = ‘%U‘ AND domain = ‘%d‘
125 user_query = SELECT maildir, 600 AS uid, 600 AS gid FROM muser WHERE username = ‘%u‘
yum install dovecot-mysql.x86_64 -y 安装服务
systemctl restart dovecot
[邮件空壳](实际不处理信息,只负责将信息转发)
client机:
配置基础dns
vim /etc/named.rfc1912.zones
zone "westos.org" IN {
type master;
file "westos.org.zone";
allow-update { none; };
};
cd /var/named/
cp -p named.localhost westos.org.zone
vim westos.org.zone
$TTL 1D
@ IN SOA dns.westos.org rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.westos.org.
dns A 172.25.49.100
westos.org. MX 1 172.25.49.10.
vim /etc/postfix/main.cf
75 myhostname = westos.com 真实主机名
83 mydomain = westos.com 域名
98myorigin = westos.org 空壳名
113 inet_interfaces = all
140 local_transport = error:local delivery disabled
164 mydestination =
313 relayhost = 172.25.49.10 真实的服务端
systemctl restart postfix 重启服务
主机
vim /etc/postfix/main.cf
264 mynetworks = 172.25.49.100 谁是空壳(172.25.49.100)
systemctl restart postfix.service 重启服务