####拒绝某个ip的邮件####
vim /etc/postfix/access
172.25.254.132 REJECT ##last line add
postmap access ##encrpy this file
postconf -e "smtpd_client_restrictions = check_client_access hash:/etc/postfix/access"
systemctl restart postfix.service ##restart service
yum install telnet -y ##test successfully (westos pc test)
telnet 172.25.254.232 25
mail from:root@linux.com
250 2.1.0 Ok
rcpt to:root@westos.com
554 5.7.1 <unknown[172.25.254.132]>: Client host rejected: Access denied
####拒绝某个用户发邮件####
vim sender
add : student@linux.com REJECT ##student user can not send mail
postmap sender
postconf -e "smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender"
systemctl restart postfix.service
########################################################################################
test: OK
[root@mailwestos ~]# telnet 172.25.254.232 25
Trying 172.25.254.232...
Connected to 172.25.254.232.
Escape character is '^]'.
220 mailelinux.linux.com ESMTP Postfix
mail from:root@linux.com
250 2.1.0 Ok
rcpt to:root@westos.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
sdfsdf
sdfsdf
.
250 2.0.0 Ok: queued as 4E91E24624B
quit
221 2.0.0 Bye
test: FAIL
[root@mailwestos ~]# telnet 172.25.254.232 25
Trying 172.25.254.232...
Connected to 172.25.254.232.
Escape character is '^]'.
220 mailelinux.linux.com ESMTP Postfix
mail from:student@linux.com
250 2.1.0 Ok
rcpt to:root@westos.com
554 5.7.1 <student@linux.com>: Sender address rejected: Access denied
###################################################################################
####拒绝某个用户的邮件####
vim recip
add : student@linux.com REJECT
postmap recip
postconf -e "smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recip"
systemctl restart postfix.service
test: fail
[root@mailwestos ~]# telnet 172.25.254.232 25
Trying 172.25.254.232...
Connected to 172.25.254.232.
Escape character is '^]'.
220 mailelinux.linux.com ESMTP Postfix
mail from:root@linux.com
250 2.1.0 Ok
rcpt to:student@linux.com
554 5.7.1 <student@linux.com>: Recipient address rejected: Access denied
####about dovecot#### 图形化邮件
yum install dovecot -y ##install dovecot
vim /etc/dovecot/dovecot.conf
24 protocols = imap pop3 lmtp
49 disable_plaintext_auth = no
cd /etc/dovecot/conf.d/
vim 10-mail.conf
30 mail_location = mbox:~/mail:INBOX=/var/mail/%u
systemctl restart dovecot ##restart dovecot
netstat -antlpe | grep dovecot ##check port
注意:imap 143 pop3 110 imaps 993 pop3s 995
测试主机里
yum install mutt -y ##install mutt software
mutt -f imap://westos@172.25.254.11 ##westos 要是在dovecot主机里有的用户,而且要有密码
问题解决:dovecot主机里,切换到westos用户状态
在/home/westos/mail文件夹里建立(.imap/INBOX) ##westos用户状态下是关键,INBOX是文件,.imap是文件夹
####thunderbird use####
download thunderbird-31.4.0.tar.bz2
tar jxf thunderbird-31.4.0.tar.bz2
vim /etc/dovecot/dovecot.conf
48 login_trusted_networks = 0.0.0.0/0
cd thunderbird/
./thunderbird ##
yum whatprovides libXt.so.6 ##缺啥装啥
yum install libXt-1.1.4-6.1.el7.i686 -y ##
您的大名:westos
电子邮件地址:westos@linux.com ##点击“继续”
密码:(你的密码)
收件 IMAP 172.25.254.11 143 无 自动检测
寄件 SMTP 172.25.254.11 25 无 自动检测
使用者名称 westos 寄件 westos ##点击“重新检测”。OK
####虚拟邮件用户,postfix与mysql连立
create email database and muser table
MariaDB [(none)]> select * from email.muser;
+----------------+----------+-----------+-----------------+
| username | password | domain | maildir |
+----------------+----------+-----------+-----------------+
| wang@linux.org | 12345 | linux.org | linux.org/wang/ |
| pwd@linux.org | 12345 | linux.org | linux.org/pwd/ |
+----------------+----------+-----------+-----------------+
log mysql -uroot -predhat
CREATE USER postfixd@localhost identified by 'postfixd';
GRANT INSERT,UPDATE,SELECT on email.* to postfixd@localhost; ##secure
create three file
[root@11linux postfix]# cat mysql-users.cf
hosts = localhost
user = postfixd
password = postfixd
dbname = email
table = muser
select_field = username
where_field = username
[root@11linux postfix]# cat mysql-domain.cf
hosts = localhost
user = postfixd
password = postfixd
dbname = email
table = muser
select_field = domain
where_field = domain
[root@11linux postfix]# cat mysql-maildir.cf
hosts = localhost
user = postfixd
password = postfixd
dbname = email
table = muser
select_field = maildir
where_field = username
750 postconf -e "virtual_gid_maps = static:666"
751 postconf -e "virtual_uid_maps = static:666"
754 postconf -e "virtual_mailbox_base = /home/vmail"
755 postconf -e "virtual_alias_maps = mysql:/etc/postfix/mysql-users.cf"
756 postconf -e "virtual_mailbox_domains = mysql:/etc/postfix/mysql-domain.cf"
757 postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mysql-maildir.cf"
postmap -q 'wang@linux.org' mysql:/etc/postfix/mysql-users.cf ##tests
systemctl restart postfix ##restart postfix
groupadd vmail -g 666
useradd -u 666 -g 666 vmail -s /sbin/nologin
test
[root@11linux linux.org]# mail wang@linux.org
Subject: wang
hello,xuyan!
.
EOT
#####################################################################
####dovecot与虚拟用户连立####
vim 10-auth.conf
123 !include auth-sql.conf.ext
cd /usr/share/doc/dovecot-2.2.10/example-config/
cp dovecot-sql.conf.ext /etc/dovecot/
cd /etc/dovecot/
vim dovecot-sql.conf.ext
32 driver = mysql
71 connect = host=localhost dbname=email user=postfixd password=postfixd
78 default_pass_scheme = PLAIN
107 password_query = \
108 SELECT username, domain, password \
109 FROM muser WHERE username = '%u' AND domain = '%d'
124 user_query = SELECT maildir, 666 AS uid, 666 AS gid FROM muser WHERE usernam e = '%u'
vim 10-mail.conf
30 mail_location = maildir:/home/vmail/%d/%n
168 first_valid_uid = 666
175 first_valid_gid = 666
yum install dovecot-mysql.x86_64 -y
systemctl restart dovecot
在thunderbird中添加虚拟帐号###########OK!!!!
vim /etc/postfix/access
172.25.254.132 REJECT ##last line add
postmap access ##encrpy this file
postconf -e "smtpd_client_restrictions = check_client_access hash:/etc/postfix/access"
systemctl restart postfix.service ##restart service
yum install telnet -y ##test successfully (westos pc test)
telnet 172.25.254.232 25
mail from:root@linux.com
250 2.1.0 Ok
rcpt to:root@westos.com
554 5.7.1 <unknown[172.25.254.132]>: Client host rejected: Access denied
####拒绝某个用户发邮件####
vim sender
add : student@linux.com REJECT ##student user can not send mail
postmap sender
postconf -e "smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender"
systemctl restart postfix.service
########################################################################################
test: OK
[root@mailwestos ~]# telnet 172.25.254.232 25
Trying 172.25.254.232...
Connected to 172.25.254.232.
Escape character is '^]'.
220 mailelinux.linux.com ESMTP Postfix
mail from:root@linux.com
250 2.1.0 Ok
rcpt to:root@westos.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
sdfsdf
sdfsdf
.
250 2.0.0 Ok: queued as 4E91E24624B
quit
221 2.0.0 Bye
test: FAIL
[root@mailwestos ~]# telnet 172.25.254.232 25
Trying 172.25.254.232...
Connected to 172.25.254.232.
Escape character is '^]'.
220 mailelinux.linux.com ESMTP Postfix
mail from:student@linux.com
250 2.1.0 Ok
rcpt to:root@westos.com
554 5.7.1 <student@linux.com>: Sender address rejected: Access denied
###################################################################################
####拒绝某个用户的邮件####
vim recip
add : student@linux.com REJECT
postmap recip
postconf -e "smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recip"
systemctl restart postfix.service
test: fail
[root@mailwestos ~]# telnet 172.25.254.232 25
Trying 172.25.254.232...
Connected to 172.25.254.232.
Escape character is '^]'.
220 mailelinux.linux.com ESMTP Postfix
mail from:root@linux.com
250 2.1.0 Ok
rcpt to:student@linux.com
554 5.7.1 <student@linux.com>: Recipient address rejected: Access denied
####about dovecot#### 图形化邮件
yum install dovecot -y ##install dovecot
vim /etc/dovecot/dovecot.conf
24 protocols = imap pop3 lmtp
49 disable_plaintext_auth = no
cd /etc/dovecot/conf.d/
vim 10-mail.conf
30 mail_location = mbox:~/mail:INBOX=/var/mail/%u
systemctl restart dovecot ##restart dovecot
netstat -antlpe | grep dovecot ##check port
注意:imap 143 pop3 110 imaps 993 pop3s 995
测试主机里
yum install mutt -y ##install mutt software
mutt -f imap://westos@172.25.254.11 ##westos 要是在dovecot主机里有的用户,而且要有密码
问题解决:dovecot主机里,切换到westos用户状态
在/home/westos/mail文件夹里建立(.imap/INBOX) ##westos用户状态下是关键,INBOX是文件,.imap是文件夹
####thunderbird use####
download thunderbird-31.4.0.tar.bz2
tar jxf thunderbird-31.4.0.tar.bz2
vim /etc/dovecot/dovecot.conf
48 login_trusted_networks = 0.0.0.0/0
cd thunderbird/
./thunderbird ##
yum whatprovides libXt.so.6 ##缺啥装啥
yum install libXt-1.1.4-6.1.el7.i686 -y ##
您的大名:westos
电子邮件地址:westos@linux.com ##点击“继续”
密码:(你的密码)
收件 IMAP 172.25.254.11 143 无 自动检测
寄件 SMTP 172.25.254.11 25 无 自动检测
使用者名称 westos 寄件 westos ##点击“重新检测”。OK
####虚拟邮件用户,postfix与mysql连立
create email database and muser table
MariaDB [(none)]> select * from email.muser;
+----------------+----------+-----------+-----------------+
| username | password | domain | maildir |
+----------------+----------+-----------+-----------------+
| wang@linux.org | 12345 | linux.org | linux.org/wang/ |
| pwd@linux.org | 12345 | linux.org | linux.org/pwd/ |
+----------------+----------+-----------+-----------------+
log mysql -uroot -predhat
CREATE USER postfixd@localhost identified by 'postfixd';
GRANT INSERT,UPDATE,SELECT on email.* to postfixd@localhost; ##secure
create three file
[root@11linux postfix]# cat mysql-users.cf
hosts = localhost
user = postfixd
password = postfixd
dbname = email
table = muser
select_field = username
where_field = username
[root@11linux postfix]# cat mysql-domain.cf
hosts = localhost
user = postfixd
password = postfixd
dbname = email
table = muser
select_field = domain
where_field = domain
[root@11linux postfix]# cat mysql-maildir.cf
hosts = localhost
user = postfixd
password = postfixd
dbname = email
table = muser
select_field = maildir
where_field = username
750 postconf -e "virtual_gid_maps = static:666"
751 postconf -e "virtual_uid_maps = static:666"
754 postconf -e "virtual_mailbox_base = /home/vmail"
755 postconf -e "virtual_alias_maps = mysql:/etc/postfix/mysql-users.cf"
756 postconf -e "virtual_mailbox_domains = mysql:/etc/postfix/mysql-domain.cf"
757 postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mysql-maildir.cf"
postmap -q 'wang@linux.org' mysql:/etc/postfix/mysql-users.cf ##tests
systemctl restart postfix ##restart postfix
groupadd vmail -g 666
useradd -u 666 -g 666 vmail -s /sbin/nologin
test
[root@11linux linux.org]# mail wang@linux.org
Subject: wang
hello,xuyan!
.
EOT
#####################################################################
####dovecot与虚拟用户连立####
vim 10-auth.conf
123 !include auth-sql.conf.ext
cd /usr/share/doc/dovecot-2.2.10/example-config/
cp dovecot-sql.conf.ext /etc/dovecot/
cd /etc/dovecot/
vim dovecot-sql.conf.ext
32 driver = mysql
71 connect = host=localhost dbname=email user=postfixd password=postfixd
78 default_pass_scheme = PLAIN
107 password_query = \
108 SELECT username, domain, password \
109 FROM muser WHERE username = '%u' AND domain = '%d'
124 user_query = SELECT maildir, 666 AS uid, 666 AS gid FROM muser WHERE usernam e = '%u'
vim 10-mail.conf
30 mail_location = maildir:/home/vmail/%d/%n
168 first_valid_uid = 666
175 first_valid_gid = 666
yum install dovecot-mysql.x86_64 -y
systemctl restart dovecot
在thunderbird中添加虚拟帐号###########OK!!!!