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軟件包名稱即可:

    [root@linuxprobe ~]# yum install dovecot
    Loaded plugins: langpacks, product-id, subscription-manager
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    rhel | 4.1 kB 00:00 
    Resolving Dependencies
    --> Running transaction check
    ---> Package dovecot.x86_64 1:2.2.10-4.el7 will be installed
    --> Processing Dependency: libclucene-core.so.1()(64bit) for package: 1:dovecot-2.2.10-4.el7.x86_64
    --> Processing Dependency: libclucene-shared.so.1()(64bit) for package: 1:dovecot-2.2.10-4.el7.x86_64
    --> Running transaction check
    ---> Package clucene-core.x86_64 0:2.3.3.4-11.el7 will be installed
    --> Finished Dependency Resolution
    Dependencies Resolved
    ================================================================================
     Package Arch Version Repository Size
    ================================================================================
    Installing:
     dovecot x86_64 1:2.2.10-4.el7 rhel 3.2 M
    Installing for dependencies:
     clucene-core x86_64 2.3.3.4-11.el7 rhel 528 k
    Transaction Summary
    ================================================================================
    Install 1 Package (+1 Dependent package)
    Total download size: 3.7 M
    Installed size: 12 M
    Is this ok [y/d/N]: y
    Downloading packages:
    --------------------------------------------------------------------------------
    Total 44 MB/s | 3.7 MB 00:00 
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
     Installing : clucene-core-2.3.3.4-11.el7.x86_64 1/2 
     Installing : 1:dovecot-2.2.10-4.el7.x86_64 2/2 
     Verifying : 1:dovecot-2.2.10-4.el7.x86_64 1/2 
     Verifying : clucene-core-2.3.3.4-11.el7.x86_64 2/2 
    Installed:
     dovecot.x86_64 1:2.2.10-4.el7 
    Dependency Installed:
     clucene-core.x86_64 0:2.3.3.4-11.el7 
    Complete!

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

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

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

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

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

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

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

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

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號