1、smtp工作过程
2、postfix的安装
1)先配置DNS服务
# yum remove bind-libs bind-utils
# yum -y install bind97 bind97-libs bind97-utils
options {
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";
recursion yes;
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.zones";
#vim /etc/named.rfc1912.zones 最后添加
zone "peace.com" IN {
type master;
file "peace.com.zone";
};
zone "16.172.in-addr.arpa" IN {
tyep master;
file "172.16.zone";
};
# cd /var/named/
# cat peace.com.zone
$TTL 600
$ORIGIN
peace.com. 注意这个后面的"."一定要有
@ IN SOA ns.peace.com admin.peace.com. (
2012070901
1H
10M
7D
1D )
@ IN NS ns
@ IN MX 10 mail
ns IN A 172.16.15.30
mail IN A 172.16.15.30
pop3 IN CNAME mail
# cat 172.16.zone
$TTL 600
@ IN SOA ns.peace.com admin.peace.com. (
2012070901
1H
10M
7D
1D )
@ IN NS ns.peace.com.
@ IN MX 10 mail.peace.com.
15.30 IN PTR ns.peace.com.
15.30 IN PTR mail.peace.com.
15.30 IN PTR pop3.peace.com.
# chown .named peace.com.zone 172.16.zone
# service named start
2)安装postfix,默认安装的sendmail先卸载
# rpm -e sendmail --nodeps
# yum -y install postfix
3)修改配置文件,如下:
# vim /etc/postfix/main.cf
mydoaim = peace.com 自己的域
myhostname = mail.peace.com 主机名
inet_inetfaces = $myhostname,localhost 监听
myorigin = $mydomain 发件人地址伪装
mynetworks = 127.0.0.0 指定允许中继IP网段
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
mail.$mydomain, www.$mydomain, ftp.$mydomain
本机所负责接受邮件所在域
# service postfix start
4)测试,新建两个用户
#useradd redhat
#useradd gentoo
发送邮件
# telnet mail.peace.com 25
Trying 172.16.15.30...
Connected to mail.peace.com (172.16.15.30).
Escape character is '^]'.
220 mail.peace.com ESMTP Postfix
helo
501 Syntax: HELO hostname
helo mail.peace.com
250 mail.peace.com
mail from:[email protected]
250 2.1.0 Ok
rcpt to:[email protected]
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
Subject:Hello
test.
.
250 2.0.0 Ok: queued as 3E6A1186DE4
quit
221 2.0.0 Bye
Connection closed by foreign host.
test.
Hello
&
5)可以通过查看日志,可以看到刚才的发送信息,日志如下:
# tail /var/log/maillog
Jul 9 12:16:37 localhost postfix/pickup[13823]: 3ED33186DE5: uid=503 from=<gentoo>
Jul 9 12:16:37 localhost postfix/cleanup[13887]: 3ED33186DE5: message-id=<
[email protected]>
Jul 9 12:16:37 localhost postfix/qmgr[13824]: 3ED33186DE5: from=<
[email protected]>, size=285, nrcpt=1 (queue active)
Jul 9 12:16:37 localhost postfix/local[13889]: 3ED33186DE5: to=<
[email protected]>, relay=local, delay=0.02, delays=0.01/0/0/0.01, dsn=2.0.0, status=sent (delivered to mailbox)
Jul 9 12:16:37 localhost postfix/qmgr[13824]: 3ED33186DE5: removed
3、邮件别名
# vim /etc/aliases 最后添加
jerry: tom
加载信息
# postalias /etc/aliases
# service postfix reload
发送邮件
# su - redhat
# su - tom
$ mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/tom": 1 message 1 new
& 1
Message 1:
Subject: Test
Date: Mon, 9 Jul 2012 15:04:57 +0800 (CST)
redhat to jerrry
&
可以发现有邮件了