在RHEL6.4下搭建Postfix+Dovecot邮件服务器。 实验需求:为公司搭建一台能够收信和发信的邮件服务器(192.168.100.1),为员工提供服务,公司域名为it.net.cn. 一.修改DNS服务器(192.168.100.2)上mx邮件交换记录,确保客户机能解析邮件服务器地址 1.修改DNS区域文件 # vim /var/named/it.net.cn.zone $TTL 3H @ IN SOA it.net.cn. root.it.net.cn. ( 2014042601; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum NS dns1.it.net.cn. IN MX 10 mail.it.net.cn. dns1 IN A 192.168.100.2 mail IN A 192.168.100.1 ……
# service named restart
# host -t mx it.net.cn 192.168.100.2 //查询目标域的MX记录 Using domain server: Name: 192.168.100.2 Address: 192.168.100.2#53 Aliases: it.net.cn mail is handled by 10 mail.it.net.cn.
Using domain server: Name: 192.168.100.2 Address: 192.168.100.2#53 Aliases: mail.it.net.cn has address 192.168.100.1
1.安装软件包 # yum -y install postfix
[root@mail ~]# cd /etc/postfix/ # postconf -n > tmp.txt //导出非默认配置 # mv main.cf main.cf.bak # mv tmp.txt main.cf # vim main.cf ... 9 #inet_interfaces = localhost //监听端口 22 myhostname = mail.it.net.cn //邮件服务器主机名 23 mydomain = it.net.cn //邮件服务器所在区域 24 myorigin = $mydomain //发件人DNS后缀 25 mydestination = $mydomain //指定Postfix允许处理的邮件 26 home_mailbox = Maildir/ //邮箱类型
# postfix check # service postfix start # chkconfig postfix on # netstat -tulnp | grep :25 //发信使用SMTP协议 tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 3564/master tcp 0 0 :::25 :::* LISTEN 3564/master
# useradd damao # echo 123456| passwd --stdin damao # useradd tom # echo 123456| passwd --stdin tom
# telnet mail.it.net.cn 25 Trying 192.168.100.1... Connected to mail.it.net.cn. Escape character is '^]'. 220 mail.it.net.cn ESMTP Postfix helo localhost //宣告客户端 250 mail.it.net.cn mail from:damao@it.net.cn //邮件发件人 250 2.1.0 Ok rcpt to:tom@it.net.cn //邮件收件人 250 2.1.5 Ok data //邮件正文 354 End data with <CR><LF>.<CR><LF> subject:Test mail //邮件主题 hello,tom //邮件内容 . //独立.表示邮件结束 250 2.0.0 Ok: queued as 9B6463FD97 quit //退出 221 2.0.0 Bye Connection closed by foreign host.
# ls /home/tom/Maildir/new/ 1398492202.V803Ibf420M185454.mail.it.net.cn # cat /home/tom/Maildir/new/1398492202.V803Ibf420M185454.mail.it.net.cn Return-Path: <damao@it.net.cn> X-Original-To: tom@it.net.cn Delivered-To: tom@it.net.cn Received: from localhost (unknown [192.168.100.1]) by mail.it.net.cn (Postfix) with SMTP id 9B6463FD97 for <tom@it.net.cn>; Fri, 25 Apr 2014 23:00:32 -0700 (PDT) subject:Test mail Message-Id: <20140426060137.9B6463FD97@mail.it.net.cn> Date: Fri, 25 Apr 2014 23:00:32 -0700 (PDT) From: damao@it.net.cn To: undisclosed-recipients:;
|