编译安装dovecot


创建运行用户

[root@jason ~]# useradd -M -s /sbin/nologin dovecot
[root@jason ~]# useradd -M -s /sbin/nologin dovenull

解压

[root@jason home]# tar xzf dovecot-2.0.21.tar.gz -C /usr/src
[root@jason home]# cd /usr/src/dovecot-2.0.21/
[root@jason dovecot-2.0.21]#

编译安装

[root@jason dovecot-2.0.21]# ./configure --sysconfdir=/etc/ --with-pam
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
...//中间省略
checking for an implementation of va_copy()... yes
checking for an implementation of __va_copy()... yes
checking whether va_lists can be copied by value... no
checking for dlopen... no
checking for dlopen in -ldl... yes
checking for SSL_read in -lssl... no
checking for getspnam... yes
checking shadow.h usability... yes
checking shadow.h presence... yes
checking for shadow.h... yes
checking for pam_start in -lpam... no
configure: error: Can't build with PAM support: libpam not found
[root@jason dovecot-2.0.21]#

注意 configure: error: Can't build with PAM support: libpam not found 此处报错

[root@jason dovecot-2.0.21]# rpm -qa | grep pam-devel
[root@jason dovecot-2.0.21]# yum install pam-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package pam-devel.x86_64 0:1.1.1-17.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================
 Package Arch Version Repository Size
========================================================================================================
Installing:
 pam-devel x86_64 1.1.1-17.el6 CentOS6.5 204 k
Transaction Summary
========================================================================================================
Install 1 Package(s)
Total download size: 204 k
Installed size: 548 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
 Installing : pam-devel-1.1.1-17.el6.x86_64 1/1
 Verifying : pam-devel-1.1.1-17.el6.x86_64 1/1
Installed:
 pam-devel.x86_64 0:1.1.1-17.el6
Complete!
[root@jason dovecot-2.0.21]#
[root@jason dovecot-2.0.21]# make
make: *** No targets specified and no makefile found. Stop.
[root@jason dovecot-2.0.21]# yum install openssl-devel

这里并不知道是pam-devel还是openssl-devel解决的问题,因为安装完成pam-devel之后并没有执行./configure --sysconfdir=/etc/ --with-pam

再次执行 ./configure --sysconfdir=/etc/ --with-pam

[root@jason dovecot-2.0.21]# ./configure --sysconfdir=/etc/ --with-pam
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
...//中间省略
config.status: creating stamp.h
config.status: creating dovecot-config.in
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
Install prefix . : /usr/local
File offsets ... : 64bit
I/O polling .... : epoll
I/O notifys .... : inotify
SSL ............ : yes (OpenSSL)
GSSAPI ......... : no
passdbs ........ : static passwd passwd-file shadow pam checkpassword
 : -bsdauth -sia -ldap -sql -vpopmail
userdbs ........ : static prefetch passwd passwd-file checkpassword nss
 : -ldap -sql -vpopmail
SQL drivers .... :
 : -pgsql -mysql -sqlite
[root@jason dovecot-2.0.21]#

make

[root@jason dovecot-2.0.21]# make
...//省略
/bin/sh ./sed.sh . /usr/local/var/run/dovecot /etc/dovecot \
 < ./dovecot.1.in > dovecot.1
/bin/sh ./sed.sh . /usr/local/var/run/dovecot /etc/dovecot \
 < ./dovecot-lda.1.in > dovecot-lda.1
/bin/sh ./sed.sh . /usr/local/var/run/dovecot /etc/dovecot \
 < ./dsync.1.in > dsync.1
make[3]: Leaving directory `/usr/src/dovecot-2.0.21/doc/man'
Making all in wiki
make[3]: Entering directory `/usr/src/dovecot-2.0.21/doc/wiki'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/usr/src/dovecot-2.0.21/doc/wiki'
Making all in example-config
make[3]: Entering directory `/usr/src/dovecot-2.0.21/doc/example-config'
Making all in conf.d
make[4]: Entering directory `/usr/src/dovecot-2.0.21/doc/example-config/conf.d'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/usr/src/dovecot-2.0.21/doc/example-config/conf.d'
make[4]: Entering directory `/usr/src/dovecot-2.0.21/doc/example-config'
cat ./README.in | sed "s|@exampledir@|/usr/local/share/doc/dovecot/example-config|" > README
make[4]: Leaving directory `/usr/src/dovecot-2.0.21/doc/example-config'
make[3]: Leaving directory `/usr/src/dovecot-2.0.21/doc/example-config'
make[3]: Entering directory `/usr/src/dovecot-2.0.21/doc'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/usr/src/dovecot-2.0.21/doc'
make[2]: Leaving directory `/usr/src/dovecot-2.0.21/doc'
make[1]: Leaving directory `/usr/src/dovecot-2.0.21'

make install

[root@jason dovecot-2.0.21]# make install

添加dovecot为系统服务

[root@jason dovecot-2.0.21]# cp doc/dovecot-initd.sh /etc/init.d/dovecot
[root@jason dovecot-2.0.21]# chmod +x /etc/init.d/dovecot
[root@jason dovecot-2.0.21]# chkconfig --add dovecot

根据样例,修改配置文

[root@jason ~]# cp -r /usr/local/share/doc/dovecot/example-config/* /etc/dovecot/

建立pam认证

[root@jason ~]# vim /etc/pam.d/dovecot
#%PAM-1.0
auth required pam_nologin.so
auth include system-auth
auth include system-auth
account include system-auth
session include system-auth
~
~
~
...//中间省略
~
~
:wq

调整主配置文件

[root@jason ~]# vim /etc/dovecot/dovecot.conf
# startup and passed down to all of its child processes. You can also give
# key=value pairs to always set specific settings.
#import_environment = TZ
##
## Dictionary server settings
##
# Dictionary can be used to store key=value lists. This is used by several
# plugins. The dictionary can be accessed either directly or though a
# dictionary server. The following dict block maps dictionary names to URIs
# when the server is used. These can then be referenced using URIs in format
# "proxy::".
dict {
 #quota = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
 #expire = sqlite:/etc/dovecot/dovecot-dict-sql.conf.ext
}
# Most of the actual configuration gets included below. The filenames are
# first sorted by their ASCII value and parsed in that order. The 00-prefixes
# in filenames are intended to make it easier to understand the ordering.
!include conf.d/10-auth.conf
ssl = no
disable_plaintext_auth = no
mail_location = maildir:~/Maildir
# A config file can also tried to be included without giving an error if
...//中间省略
:wq

启动dovecot,查看监听状

[root@jason ~]# /etc/init.d/dovecot start
Starting Dovecot.
[root@jason ~]# netstat -utpln | grep dovecot
tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 41183/dovecot
tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 41183/dovecot
tcp 0 0 :::110 :::* LISTEN 41183/dovecot
tcp 0 0 :::143 :::* LISTEN 41183/dovecot
[root@jason ~]#

配置DNS

[root@jason ~]# yum install bind
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package bind.x86_64 32:9.8.2-0.17.rc1.el6_4.6 will be installed
--> Processing Dependency: bind-libs = 32:9.8.2-0.17.rc1.el6_4.6 for package: 32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64
--> Processing Dependency: portreserve for package: 32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64
--> Processing Dependency: liblwres.so.80()(64bit) for package: 32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64
--> Processing Dependency: libisccfg.so.82()(64bit) for package: 32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64
--> Processing Dependency: libisccc.so.80()(64bit) for package: 32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64
--> Processing Dependency: libisc.so.83()(64bit) for package: 32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64
--> Processing Dependency: libdns.so.81()(64bit) for package: 32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64
--> Processing Dependency: libbind9.so.80()(64bit) for package: 32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64
--> Running transaction check
---> Package bind-libs.x86_64 32:9.8.2-0.17.rc1.el6_4.6 will be installed
---> Package portreserve.x86_64 0:0.0.4-9.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================
 Package Arch Version Repository Size
========================================================================================================
Installing:
 bind x86_64 32:9.8.2-0.17.rc1.el6_4.6 CentOS6.5 4.0 M
Installing for dependencies:
 bind-libs x86_64 32:9.8.2-0.17.rc1.el6_4.6 CentOS6.5 878 k
 portreserve x86_64 0.0.4-9.el6 CentOS6.5 23 k
Transaction Summary
========================================================================================================
Install 3 Package(s)
Total download size: 4.9 M
Installed size: 9.5 M
Is this ok [y/N]: y
Downloading Packages:
--------------------------------------------------------------------------------------------------------
Total 33 MB/s | 4.9 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
 Installing : portreserve-0.0.4-9.el6.x86_64 1/3
 Installing : 32:bind-libs-9.8.2-0.17.rc1.el6_4.6.x86_64 2/3
 Installing : 32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64 3/3
 Verifying : 32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64 1/3
 Verifying : 32:bind-libs-9.8.2-0.17.rc1.el6_4.6.x86_64 2/3
 Verifying : portreserve-0.0.4-9.el6.x86_64 3/3
Installed:
 bind.x86_64 32:9.8.2-0.17.rc1.el6_4.6
Dependency Installed:
 bind-libs.x86_64 32:9.8.2-0.17.rc1.el6_4.6 portreserve.x86_64 0:0.0.4-9.el6
Complete!
[root@jason ~]# yum install bind

hostnam

[root@ns1 named]# hostname
ns1.benet.com

hosts

[root@ns1 named]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
173.16.16.18 ns1.benet.com ns1
[root@ns1 named]#

resolv.conf

[root@ns1 named]# cat /etc/resolv.conf
nameserver 173.16.16.18

benet.com.zone权限

[root@ns1 named]# ls -l benet.com.zone
-rw-r--r--. 1 named root 186 Jul 11 01:47 benet.com.zone

编辑dns主配置文件

//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options {
 listen-on port 53 { any; };
 listen-on-v6 port 53 { ::1; };
 directory "/var/named";
 dump-file "/var/named/data/cache_dump.db";
 statistics-file "/var/named/data/named_stats.txt";
 memstatistics-file "/var/named/data/named_mem_stats.txt";
 allow-query { any; };
 recursion yes;
 dnssec-enable yes;
 dnssec-validation yes;
 dnssec-lookaside auto;
 /* Path to ISC DLV key */
 bindkeys-file "/etc/named.iscdlv.key";
 managed-keys-directory "/var/named/dynamic";
};
logging {
 channel default_debug {
 file "data/named.run";
 severity dynamic;
 };
};
zone "benet.com." IN {
 type master;
 file "benet.com.zone";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

编辑benet.com.zon

[root@jason named]# vim benet.com.zone
$TTL 86440
@ IN SOA benet.com. admin.benet.com (
 20160721
 3H
 15M
 1W
 1D
)
@ IN NS ns1.benet.com.
ns1 IN A 173.16.16.18
 IN MX 10 mail.benet.com.
mail IN A 173.16.16.18

测试DNS

[root@ns1 named]# nslookup mail.benet.com
Server: 173.16.16.18
Address: 173.16.16.18#53
Name: mail.benet.com
Address: 173.16.16.18

注意没有telnet两个包会影响后续的实验

[root@mail ~]# rpm -qa | grep telnet
telnet-0.17-47.el6_3.1.x86_64
telnet-server-0.17-47.el6_3.1.x86_64

安装telnet-server

[root@ns1 named]# yum install telnet-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package telnet-server.x86_64 1:0.17-47.el6_3.1 will be installed
--> Processing Dependency: xinetd for package: 1:telnet-server-0.17-47.el6_3.1.x86_64
--> Running transaction check
---> Package xinetd.x86_64 2:2.3.14-39.el6_4 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================
 Package Arch Version Repository Size
========================================================================================================
Installing:
 telnet-server x86_64 1:0.17-47.el6_3.1 CentOS6.5 37 k
Installing for dependencies:
 xinetd x86_64 2:2.3.14-39.el6_4 CentOS6.5 121 k
Transaction Summary
========================================================================================================
Install 2 Package(s)
Total download size: 158 k
Installed size: 313 k
Is this ok [y/N]: y
Downloading Packages:
--------------------------------------------------------------------------------------------------------
Total 3.3 MB/s | 158 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
 Installing : 2:xinetd-2.3.14-39.el6_4.x86_64 1/2
 Installing : 1:telnet-server-0.17-47.el6_3.1.x86_64 2/2
 Verifying : 2:xinetd-2.3.14-39.el6_4.x86_64 1/2
 Verifying : 1:telnet-server-0.17-47.el6_3.1.x86_64 2/2
Installed:
 telnet-server.x86_64 1:0.17-47.el6_3.1
Dependency Installed:
 xinetd.x86_64 2:2.3.14-39.el6_4
Complete!

安装完成后测试

[root@ns1 named]#
[root@ns1 named]# /etc/init.d/xinetd start
Starting xinetd: [ OK ]
[root@ns1 named]# chkconfig telnet on
[root@ns1 named]# telnet 173.16.16.18 25
Trying 173.16.16.18...
telnet: connect to address 173.16.16.18: Connection refused
[root@ns1 named]# vi /etc/sysconfig/network
[root@ns1 named]# reboot

telnet依旧无法连接

安装完成后重启

重启后测试

[root@mail ~]# telnet 173.16.16.18 25
Trying 173.16.16.18...
Connected to 173.16.16.18.
Escape character is '^]'.
220 mail.benet.com ESMTP Postfix

测试成功


Outlook

添加用户

点击文件

添加用户

选择手动设置

选择服务

测试用户名为[email protected]

测试结果

测试mail.benet.com

mail.benet.com 测试结果

服务器写IP地址+用户名写

输入密码

第二次输入密码

测试结果

测试173.16.16.18

173.16.16.18测试结果

成功添加用户后

发送邮件测试

outlook jason-->>bourn发送邮件

收到的邮件路径

[root@mail new]# pwd
/home/bourn/Maildir/new

查看刚刚收到的邮件

[root@mail new]# date
Mon Jul 11 03:00:54 CST 2016
[root@mail new]# ls -l
total 4
-rw-------. 1 bourn mailusers 2846 Jul 11 02:58 1468177037.Vfd00I4111fM992657.mail.benet.com
[root@mail new]#
[root@mail new]# cat 1468177037.Vfd00I4111fM992657.mail.benet.com
Return-Path: 
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: from SC201605161314 (unknown [173.16.16.2])
 by mail.benet.com (Postfix) with ESMTP id E1620BFE36;
 Mon, 11 Jul 2016 02:57:17 +0800 (CST)
From: "bourn" 
To: 
Cc: 
Subject: Test
Date: Fri, 22 Jul 2016 00:13:52 +0800
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: multipart/alternative;
 boundary="----=_NextPart_000_0080_01D1E3AD.ED938350"
X-Mailer: Microsoft Outlook 16.0
Thread-Index: AdHjar+8UMn7UMo6QW+wLkka5BgwpQ==
Content-Language: en-us
This is a multipart message in MIME format.
------=_NextPart_000_0080_01D1E3AD.ED938350
Content-Type: text/plain;
 charset="us-ascii"
Content-Transfer-Encoding: 7bit
This is a test from win10 outlook!
------=_NextPart_000_0080_01D1E3AD.ED938350
Content-Type: text/html;
 charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

This is a test from win10 outlook! =

------=_NextPart_000_0080_01D1E3AD.ED938350-- [root@mail new]#

results matching ""

    No results matching ""