15.2.2 配置Dovecot服務(wù)程序

2022-06-01 09:28 更新

Dovecot是一款能夠為Linux系統(tǒng)提供IMAP和POP3電子郵件服務(wù)的開源服務(wù)程序,安全性極高,配置簡單,執(zhí)行速度快,而且占用的服務(wù)器硬件資源也較少,因此是一款值得推薦的收件服務(wù)程序。

第1步:安裝Dovecot服務(wù)程序軟件包。大家可自行配置Yum軟件倉庫、掛載光盤鏡像到指定目錄,然后輸入要安裝的dovecot軟件包名稱即可:

  1. [root@linuxprobe ~]# yum install dovecot
  2. Loaded plugins: langpacks, product-id, subscription-manager
  3. This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
  4. rhel | 4.1 kB 00:00
  5. Resolving Dependencies
  6. --> Running transaction check
  7. ---> Package dovecot.x86_64 1:2.2.10-4.el7 will be installed
  8. --> Processing Dependency: libclucene-core.so.1()(64bit) for package: 1:dovecot-2.2.10-4.el7.x86_64
  9. --> Processing Dependency: libclucene-shared.so.1()(64bit) for package: 1:dovecot-2.2.10-4.el7.x86_64
  10. --> Running transaction check
  11. ---> Package clucene-core.x86_64 0:2.3.3.4-11.el7 will be installed
  12. --> Finished Dependency Resolution
  13. Dependencies Resolved
  14. ================================================================================
  15. Package Arch Version Repository Size
  16. ================================================================================
  17. Installing:
  18. dovecot x86_64 1:2.2.10-4.el7 rhel 3.2 M
  19. Installing for dependencies:
  20. clucene-core x86_64 2.3.3.4-11.el7 rhel 528 k
  21. Transaction Summary
  22. ================================================================================
  23. Install 1 Package (+1 Dependent package)
  24. Total download size: 3.7 M
  25. Installed size: 12 M
  26. Is this ok [y/d/N]: y
  27. Downloading packages:
  28. --------------------------------------------------------------------------------
  29. Total 44 MB/s | 3.7 MB 00:00
  30. Running transaction check
  31. Running transaction test
  32. Transaction test succeeded
  33. Running transaction
  34. Installing : clucene-core-2.3.3.4-11.el7.x86_64 1/2
  35. Installing : 1:dovecot-2.2.10-4.el7.x86_64 2/2
  36. Verifying : 1:dovecot-2.2.10-4.el7.x86_64 1/2
  37. Verifying : clucene-core-2.3.3.4-11.el7.x86_64 2/2
  38. Installed:
  39. dovecot.x86_64 1:2.2.10-4.el7
  40. Dependency Installed:
  41. clucene-core.x86_64 0:2.3.3.4-11.el7
  42. Complete!

第2步:配置部署Dovecot服務(wù)程序。在Dovecot服務(wù)程序的主配置文件中進(jìn)行如下修改。首先是第24行,把Dovecot服務(wù)程序支持的電子郵件協(xié)議修改為imap、pop3和lmtp。然后在這一行下面添加一行參數(shù),允許用戶使用明文進(jìn)行密碼驗證。之所以這樣操作,是因為Dovecot服務(wù)程序為了保證電子郵件系統(tǒng)的安全而默認(rèn)強制用戶使用加密方式進(jìn)行登錄,而由于當(dāng)前還沒有加密系統(tǒng),因此需要添加該參數(shù)來允許用戶的明文登錄。

  1. [root@linuxprobe ~]# vim /etc/dovecot/dovecot.conf
  2. ………………省略部分輸出信息………………
  3. 23 # Protocols we want to be serving.
  4. 24 protocols = imap pop3 lmtp
  5. 25 disable_plaintext_auth = no
  6. ………………省略部分輸出信息………………

在主配置文件中的第48行,設(shè)置允許登錄的網(wǎng)段地址,也就是說我們可以在這里限制只有來自于某個網(wǎng)段的用戶才能使用電子郵件系統(tǒng)。如果想允許所有人都能使用,則不用修改本參數(shù):

  1. 44 # Space separated list of trusted network ranges. Connections from these
  2. 45 # IPs are allowed to override their IP addresses and ports (for logging and
  3. 46 # for authentication checks). disable_plaintext_auth is also ignored for
  4. 47 # these networks. Typically you'd specify your IMAP proxy servers here.
  5. 48 login_trusted_networks = 192.168.10.0/24

第3步:配置郵件格式與存儲路徑。在Dovecot服務(wù)程序單獨的子配置文件中,定義一個路徑,用于指定要將收到的郵件存放到服務(wù)器本地的哪個位置。這個路徑默認(rèn)已經(jīng)定義好了,我們只需要將該配置文件中第24行前面的井號(#)刪除即可。

  1. [root@linuxprobe ~]# vim /etc/dovecot/conf.d/10-mail.conf
  2. 1 ##
  3. 2 ## Mailbox locations and namespaces
  4. 3 ##
  5. 4 # Location for users' mailboxes. The default is empty, which means that Dovecot
  6. 5 # tries to find the mailboxes automatically. This won't work if the user
  7. 6 # doesn't yet have any mail, so you should explicitly tell Dovecot the full
  8. 7 # location.
  9. 8 #
  10. 9 # If you're using mbox, giving a path to the INBOX file (eg. /var/mail/%u)
  11. 10 # isn't enough. You'll also need to tell Dovecot where the other mailboxes are
  12. 11 # kept. This is called the "root mail directory", and it must be the first
  13. 12 # path given in the mail_location setting.
  14. 13 #
  15. 14 # There are a few special variables you can use, eg.:
  16. 15 #
  17. 16 # %u - username
  18. 17 # %n - user part in user@domain, same as %u if there's no domain
  19. 18 # %d - domain part in user@domain, empty if there's no domain
  20. 19 # %h - home directory
  21. 20 #
  22. 21 # See doc/wiki/Variables.txt for full list. Some examples:
  23. 22 #
  24. 23 # mail_location = maildir:~/Maildir
  25. 24 mail_location = mbox:~/mail:INBOX=/var/mail/%u
  26. 25 # mail_location = mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%n
  27. ………………省略部分輸出信息………………

然后切換到配置Postfix服務(wù)程序時創(chuàng)建的boss賬戶,并在家目錄中建立用于保存郵件的目錄。記得要重啟Dovecot服務(wù)并將其添加到開機啟動項中。至此,對Dovecot服務(wù)程序的配置部署步驟全部結(jié)束。

  1. [root@linuxprobe ~]# su - boss
  2. Last login: Sat Aug 15 16:15:58 CST 2017 on pts/1
  3. [boss@mail ~]$ mkdir -p mail/.imap/INBOX
  4. [boss@mail ~]$ exit
  5. [root@linuxprobe ~]# systemctl restart dovecot
  6. [root@linuxprobe ~]# systemctl enable dovecot
  7. ln -s '/usr/lib/systemd/system/dovecot.service' '/etc/systemd/system/multi-user.target.wants/dovecot.service'
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號