vim /etc/named.conf
//listen-on port 53 { 127.0.0.1;};
//listen-on-v6 port 53 { ::1;};
//allow-query { localhost;};
1
2
3
4
直接注释listen与allow-query,就可以监听在所有地址上并且允许所有主机访问
定义正反向区域配置文件
vim /etc/named.rfc1912.zones
zone "zhongdianjizhi.com" IN {type master;file"zhongdianjizhi.com.zone";};
zone "118.168.192.in-addr.arpa"{type master;file"zhongdianjizhi.com.local";};
1
2
3
4
5
6
7
8
9
定义区域解析库文件(配置A记录与MX记录)
cd /var/named
cp -p named.localhost zhongdianjizhi.com.zone
cp -p named.localhost zhongdianjizhi.com.local
vim /var/named/zhongdianjizhi.com.zone
$TTL 86400
@ IN SOA ns.zhongdianjizhi.com. admin.zhongdianjizhi.com. (
201902 ; serial
2H ; refresh
10M ; retry
3D ; expire
1D ); minimum
IN NS ns
IN MX 10 mail
ns IN A 192.168.118.100
mail IN A 192.168.118.100
vim /var/named/zhongdianjizhi.com.local
$TTL 86400
@ IN SOA ns.zhongdianjizhi.com. admin.zhongdianjizhi.com. (
201902 ; serial
2H ; refresh
10M ; retry
3D ; expire
1D ); minimum
IN NS ns.zhongdianjizhi.com.
1 IN PTR ns.zhongdianjizhi.com.
1 IN PTR mail.zhongdianjizhi.com.
Please specify the prefix for installed file names. Specify this ONLY
if you are building ready-to-install packages for distribution to OTHER
machines. See PACKAGE_README for instructions.
install_root: [/]
Please specify a directory for scratch files while installing Postfix. You
must have write permission in this directory.
tempdir: [/usr/local/src/postfix-3.0.11] /tmp/extmail #更改tmp目录,其他的全部默认
Please specify the final destination directory for installed Postfix
configuration files.
config_directory: [/etc/postfix]
Please specify the final destination directory for installed Postfix
administrative commands. This directory should be in the command search
path of adminstrative users.
command_directory: [/usr/sbin]
Please specify the final destination directory for installed Postfix
daemon programs. This directory should not be in the command search path
of any users.
daemon_directory: [/usr/libexec/postfix]
Please specify the final destination directory for Postfix-writable
data files such as caches or random numbers. This directory should not
be shared with non-Postfix software.
data_directory: [/var/lib/postfix]
Please specify the final destination directory for the Postfix HTML
files. Specify "no"if you do not want to install these files.
html_directory: [no]
Please specify the owner of the Postfix queue. Specify an account with
numerical user ID and group ID values that are not used by any other
accounts on the system.
mail_owner: [postfix]
Please specify the final destination pathname for the installed Postfix
mailq command. This is the Sendmail-compatible mail queue listing command.
mailq_path: [/usr/bin/mailq]
Please specify the final destination directory for the Postfix on-line
manual pages. You can no longer specify "no" here.
manpage_directory: [/usr/local/man]
Please specify the final destination pathname for the installed Postfix
newaliases command. This is the Sendmail-compatible command to build
alias databases for the Postfix local delivery agent.
newaliases_path: [/usr/bin/newaliases]
Please specify the final destination directory for Postfix queues.
queue_directory: [/var/spool/postfix]
Please specify the final destination directory for the Postfix README
files. Specify "no"if you do not want to install these files.
readme_directory: [no]
Please specify the final destination pathname for the installed Postfix
sendmail command. This is the Sendmail-compatible mail posting interface.
sendmail_path: [/usr/sbin/sendmail]
Please specify the group for mail submission and for queue management
commands. Specify a group name with a numerical group ID that is
not shared with other accounts, not even with the Postfix mail_owner
account. You can no longer specify "no" here.
setgid_group: [postdrop]
Please specify the final destination directory for Postfix shared-library
files.
shlib_directory: [no]
useradd jym
systemctl start postfix
[root@mail ~]# telnet mail.zhongdianjizhi.com 25
Trying fe80::4c54:bb23:c6db:6473%ens33...
telnet: connect to address fe80::4c54:bb23:c6db:6473%ens33: Connection refused
Trying 192.168.118.100...
Connected to mail.zhongdianjizhi.com.
Escape character is '^]'.
220 mail.zhongdianjizhi.com ESMTP Postfix
mail from:root@zhongdianjizhi.com
250 2.1.0 Ok
rcpt to:jym@zhongdianjizhi.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
hello,this is test mail.
.
250 2.0.0 Ok: queued as 13259132D75
quit
221 2.0.0 Bye
Connection closed by foreign host.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Note:写完邮件正文需要以.结束 发送成功
[root@mail ~]# tail /var/log/maillog|grep sent
Jul 1 16:29:56 mail postfix/local[8749]: 13259132D75: to=<jym@zhongdianjizhi.com>, relay=local, delay=66, dela
ys=66/0.01/0/0, dsn=2.0.0, status=sent (delivered to maildir)
1
2
3
四、安装dovecot 4.1、yum安装dovecot
yum -y install dovecot dovecot-mysql
1
依赖包:clucene-core
4.2、配置dovecot
vim /etc/dovecot/dovecot.conf
#第24行,取消注释
protocols = imap pop3 lmtp
#第30行,取消注释
listen = *, ::
#第33行,取消注释
base_dir = /var/run/dovecot/
vim /etc/dovecot/conf.d/10-mail.conf
#第30行,取消注释,为dovecot指明邮箱位置
mail_location = maildir:/var/mailbox/%d/%n/Maildir
配置dovecot连接mysql
cp /etc/dovecot/conf.d/auth-sql.conf.ext /etc/dovecot/conf.d/auth-sql.conf
vim /etc/dovecot/conf.d/auth-sql.conf
passdb {
driver = sql
# Path for SQL configuration file, see example-config/dovecot-sql.conf.ext
args = /etc/dovecot/dovecot-sql.conf
}
userdb {
driver = sql
args = /etc/dovecot/dovecot-sql.conf
}
vim /etc/dovecot/dovecot-sql.conf
driver = mysql
connect = host=localhost dbname=extmail user=extmail password=extmail
default_pass_scheme = CRYPT
password_query = SELECT username AS user,password AS password FROM mailbox WHERE username ='%u'
user_query = SELECT maildir, uidnumber AS uid, gidnumber AS gid FROM mailbox WHERE username ='%u'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
4.3、启动
systemctl start dovecot.service
1
4.4、测试收件
echo"111111"|passwd --stdin jym
[root@mail ~]# telnet mail.zhongdianjizhi.com 110
Trying fe80::4c54:bb23:c6db:6473%ens33...
Connected to mail.zhongdianjizhi.com.
Escape character is '^]'.
+OK Dovecot ready.
user jym
+OK
pass 111111
+OK Logged in.
list
+OK 2 messages:
1 506
2 495
.
retr 1
+OK 506 octets
Return-Path: <root@zhongdianjizhi.com>
X-Original-To: jym@zhongdianjizhi.com
Delivered-To: jym@zhongdianjizhi.com
Received: from mail.zhongdianjizhi.com (mail.zhongdianjizhi.com [192.168.118.100])
by mail.zhongdianjizhi.com (Postfix) with ESMTP id 13259132D75
for<jym@zhongdianjizhi.com>; Mon, 1 Jul 2019 16:28:51 +0000 (GMT)
Message-Id: <20190701162941.13259132D75@mail.zhongdianjizhi.com>
Date: Mon, 1 Jul 2019 16:28:51 +0000 (GMT)
From: root@zhongdianjizhi.com
hello,this is test mail.
wget https://sourceforge.net/projects/courier/files/courier-unicode/2.1/courier-unicode-2.1.tar.bz2
tar xf courier-unicode-2.1.tar.bz2
cd courier-unicode-2.1/
./configure
make&&makeinstall