配置Dovecot服务程序
的有关信息介绍如下:Dovecot是一款能够为Linux系统提供IMAP和POP3电子邮件服务的开源软件程序,拥有极高的安全性,并且配置起来也十分简单,执行效率很快,而且占用的服务器硬件资源也较少,是非常推荐的电子邮件系统的收件服务软件。详情请关注《linux就该这么学》。
安装Dovecot服务程序软件包,请同学们先自行配置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 ResolutionDependencies 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!
配置部署Dovecot服务程序,对Dovecot服务程序的主配置文件需要修改2-3处,首先是在主配置文件中的约24行左右,把Dovecot服务程序支持的电子邮件协议修改为imap、pop3和lmtp。然后在该行的下面添加一行参数来允许客户使用明文进行密码验证,这是由于Dovecot服务程序为了保证电子邮件系统安全而默认强制客户必须使用加密方式进行登陆,而当前由于咱们没有加密系统的支持,因此需要添加参数来允许客户的明文登陆行为。
[root@linuxprobe ~] # vim /etc/dovecot/dovecot.conf
# Protocols we want to be serving.
protocols = imap pop3 lmtp
disable_plaintext_auth = no
最后是在主配置文件中的约48行左右,设置允许登陆的网段地址,也就是说同学们可以在这里限制只有来自于某个网段的客户才能使用电子邮件系统,如果想允许所有人都能来使用,可以不用修改本条参数:
# Space separated list of trusted network ranges. Connections from these
# IPs are allowed to override their IP addresses and ports (for logging and# for authentication checks). disable_plaintext_auth is also ignored for# these networks. Typically you'd specify your IMAP proxy servers here.
login_trusted_networks = 192.168.10.0/24
配置邮件格式与存储路径,需要编辑dovecot服务程序单独的子配置文件,定义要把收到的邮件信息保存到服务器本地的路径,而这个路径默认已经是被定义好的,只需要把此配置文件中第25行前面的#(井号)注释信息去掉即可:
[root@linuxprobe ~] # vim /etc/dovecot/conf.d/10-mail.conf
##
## Mailbox locations and namespaces
##
# Location for users' mailboxes. The default is empty, which means that Dovecot
# tries to find the mailboxes automatically. This won't work if the user
# doesn't yet have any mail, so you should explicitly tell Dovecot the full# location.
#
# If you're using mbox, giving a path to the INBOX file (eg. /var/mail/%u)# isn't enough. You'll also need to tell Dovecot where the other mailboxes are
# kept. This is called the "root mail directory", and it must be the first
# path given in the mail_location setting.
#
# There are a few special variables you can use, eg.:
#
# %u - username
# %n - user part in user@domain, same as %u if there's no domain
# %d - domain part in user@domain, empty if there's no domain
# %h - home directory
#
# See doc/wiki/Variables.txt for full list. Some examples:
#
# mail_location = maildir:~/Maildir
mail_location = mbox:~/mail:INBOX=/var/mail/%u
# mail_location = mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%n
………………省略部分输出信息………………
然后切换到该用户身份后在家目录中建立用于保存邮件的目录,记得重启一下服务并加入到开机启动项就完成了对Dovecot服务程序的全部配置部署步骤:
[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'