Linux郵箱伺服器配置:如何讓outlook收發郵件,怎麼樣控制中繼

來源:互聯網
上載者:User

本文基於上篇文章基礎地址:http://blog.csdn.net/deansrk/article/details/6717720

 

outlook實現收郵件


1.首先我們查看郵箱目錄裡檔案的屬主和屬組

[root@mail ~]# ll /var/mailbox/a.org/gentoo/Maildir/total 60-rw------- 1 postfix postfix 356 Aug 23 00:52 abook.cfdrwx------ 2 postfix postfix 4096 Aug 23 00:49 cur-rw------- 1 postfix postfix 8192 Aug 23 00:49 extmail-curcache.db-rw------- 1 postfix postfix 6 Aug 23 00:49 extmail-curcnt-rw------- 1 postfix postfix 24 Aug 23 00:53 maildirsizedrwx------ 2 postfix postfix 4096 Aug 23 00:49 newdrwx------ 2 postfix postfix 4096 Aug 23 00:53 tmp

# 可以看到都是postfix使用者,所以我們要訪問這些檔案,必須身份是postfix,而我們在外部收發郵件的時候,使用的不是postfix使用者,那麼該怎麼辦呢?

2.dovcot在驗證使用者是否有許可權提取郵件,驗證的是使用者自身對應的身份,而通過網頁extmail產生的使用者對應的id都是1000的使用者,那麼我們如果修改這個映射關係。

vim /var/www/extsuite/extman/webman.cf

SYS_DEFAULT_UID = 2525SYS_DEFAULT_GID = 2525# 修改這兩項為2525這樣它對應的就是uid,gid為2525使用者,也就是postfixid postfixuid=2525(postfix) gid=2525(postfix) groups=2525(postfix) context=root:system_r:unconfined_t:SystemLow-SystemHigh

 

3.開啟dovcot的debug功能來驗證是否映射變為2525
vim /etc/dovcot

auth_verbose = yesauth_debug = yesauth_debug_passwords = yeslog_path = /var/log/dovecot.log      # 我們這裡只是為了測試,在正常應用建議不要開啟,否則每一個使用者登入都要組建記錄檔,會給磁碟帶來很大的壓力,他們都儲存在/var/log/maillog,所以我們需要單獨定義一個#位置,防止在maillog裡產生造成雜亂service dovecot restart

 

4.登入郵箱,查看日誌,使用者的uid,gid是否改變(只對新信箱使用者生效)

[root@mail ~]# telnet 192.168.0.12 110Trying 192.168.0.12...Connected to ns1.a.org (192.168.0.12).Escape character is '^]'.+OK Dovecot ready.USER dean@a.org+OKPASS dean123+OK Logged in.Connection closed by foreign host.dovecot: Aug 23 05:25:18 Info: auth(default): master out: USER 1 dean@a.org maildir=a.org/dean/Maildir/ uid=1000 gid=1000

# 上面的是一個老使用者,並沒有改變uid和gid

5.修改Mysql使所有使用者都生效

mysql -uroot -predhatmysql> show databases;                                        +--------------------+| Database           |+--------------------+| information_schema | | extmail            | | mysql              | | test               | +--------------------+4 rows in set (0.00 sec)mysql> show tables;+-------------------+| Tables_in_extmail |+-------------------+| alias             | | domain            | | domain_manager    | | mailbox           | | manager           | +-------------------+5 rows in set (0.00 sec)將其他虛擬使用者的映射也改為2525update mailbox SET gidnumber=2525 WHERE uidnumber=1000;update mailbox SET gidnumber=2525 WHERE gidnumber=1000;SELECT * FROM mailbox\G           #查看是否改成2525修改後使用新帳號測試下mutt命令: pop3和imaps查看郵件和加密郵件的專用工具mutt -f mailbox                 # 指定mailboxmutt -f pop://gentoo@a.org@mail.a.org # 第一個@是郵箱帳號  第二個@後面的是郵件伺服器地址dovecot: Aug 23 21:59:34 Info: auth(default): master out: USER 6 gentoo@dean.com maildir=dean.com/gentoo/Maildir/ uid=2525 gid=2525

6.使用抓包工具tshark測試110連接埠的資料包

安裝:
yum install wireshark
# 只要是進出110連接埠的資料包都進行抓取
tshark -ni eth0 -R "tcp.dstport eq 110 or tcp.srcport eq 110"

# 測試下捕獲郵件資料包
mutt -f pop://192.168.0.12

--
# 110和143在收取郵箱和認證過程是都是銘文的,這樣在傳輸的時候都很不安全。

----------------------------------------------------------------
如何?加密郵件?

smtps: 在投遞時加密,但是郵箱需要轉寄的情況下,只要有一個不支援加密,就沒辦法加密。
SSL: 需要兩端都支援加密
S/MIME, GPG:實現端到端的郵件加密不管中間轉寄了多少主機,他們看到的郵件的內容都是加密過的,只負責轉寄郵件,使用者根據自己的私密金鑰,公開金鑰,單向密碼編譯演算法結合起來進行揭秘
          
早期的smtp協議只能傳送文本,後來通過s/mime可以實現其他形式的編碼,例如base64,這樣就可以實現加密並且發送附件,只要給伺服器端提供一個認證,pop3就升級為pop3s

----------------------------------------------------------------------------

1.建立ca

mkdir /etc/dovecotmkdir /etc/dovecot/ssl

2.給dovcot頒發認證

openssl genrsa 1024 >dovecot.keyopenssl req -new -key dovecot.key -out dovecot.reqopenssl ca -in dovecot.req -out dovecot.pem# dovcot需要使用ca的認證,必要的時候需要使用客戶的認證

3.編輯/etc/dovecot.conf

vim /etc/dovecot.conf ssl_cert_file = /etc/dovecot/ssl/dovecot.pemssl_key_file = /etc/dovecot/ssl/dovecot.keyssl_ca_file = /etc/dovecot/ssl/cacert.crt protocols = imap imaps pop3 pop3s

4.修改下dns

[root@mail ~]# cd /var/named[root@mail named]# vim dean.com.zone  pop3.dean.com.          IN      A       192.168.0.32[root@mail named]# vim 192.arpa 32            IN      PTR     pop3.dean.com.

5.測試下發送加密郵件
mutt -f pops://gentoo@a.org@pop3.a.org

6.啟動tshark再測試下
tshark -ni eth0 -R "tcp.srcp eq 995 or tcp.dstport eq 995"

------------------------------------------------------------

中繼管理

假設在一個網段,172.16.0.0 現在只需要拒絕172.16.100.100

 

vim /etc/postfix/main.cnfsmtpd_recipient_restrictions =      # 限定使用者smtpd_client_restrictions =         # 限定      

# 上面兩種限制都支援編輯某一特定的文本,通過那個文本來限制

 

# vim /etc/postfix/access#192.16.0.1 REJECT# 你也可以自己寫一個檔案vim /etc/postfix/client192.168.0.1 REJECTpostmap client          # 需要將這個檔案轉換成二進位檔案才能使用smtpd_client_restrictions = hash:/etc/postfix/client#我們在這裡使用hash格式,static格式非常慢,一般不用# postfix預設每隔一段時間自動載入設定檔

-------------------------------------------------------------------------------------
明確指定拒絕寄件者

 

smtpd_sender_restrictions = hash:/etc/postfix/sender        # 可以定義拒絕的用戶端vim sender              #裡面寫上打算拒絕的用戶端centos@a.org  REJECT    # 拒絕指定使用者@a.org        REJECT # 拒絕a.org網域名稱的所有郵件gentoo@       REJECT    # 只要是gentoo都拒絕[root@mail postfix]# telnet 192.168.0.32 25Trying 192.168.0.32...Connected to mail.dean.com (192.168.0.32).Escape character is '^]'.220 Welcome to our mail.dean.com ESMTP,Warning: Version has been hidden!helo mail.dean.com250 mail.dean.commail from:gentoo@dean.com250 2.1.0 Okrcpt to:dean@dean.com554 5.7.1 <gentoo@dean.com>: Sender address rejected: Access denied

 

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.