管理郵件

 

{**郵件的發送與接收**}

[拒絕某ip發送]

useradd westos

passwd westos

[root@westos ~]# cd /etc/postfix/

[root@westos postfix]# ls

access     generic        main.cf    relocated  virtual

canonical  header_checks  master.cf  transport

 

[root@westos postfix]# vim access  

172.25.254.149 REJECT  最後一行添加要禁止的

[root@westos postfix]# postmap access  執行完會出現新的db文件

[root@westos postfix]# ls

access     canonical  header_checks  master.cf  transport

access.db  generic    main.cf        relocated  virtual

[root@westos postfix]# postconf -d | grep client

 postconf -e "smtpd_client_restrictions = check_client_access hash:/etc/postfix/access"                

systemctl restart postfix.service     重啓服務

測試

[root@westos 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       重啓服務

測試

[root@westos 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       重啓服務

測試

[root@westos 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 postfix@localhost identified by 'postfix' ;

Query OK, 0 rows affected (0.00 sec)            創建用戶postfx

MariaDB [(none)]> GRANT INSERT,UPDATE,SELECT on email.* to postfix@localhost ;

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     重啓服務

 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章