Postfix(一)--配置

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.
切换用户查看邮件
# su - gentoo
$ mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/spool/mail/gentoo": 1 message 1 new
>N  1 [email protected]      Mon Jul  9 12:12  15/489   "Hello"
& 1
Message 1:
From [email protected]  Mon Jul  9 12:12:41 2012
X-Original-To: [email protected]
Delivered-To: [email protected]
Subject:Hello
Date: Mon,  9 Jul 2012 12:12:07 +0800 (CST)
From: [email protected]
To: undisclosed-recipients:;
test.
&
回下邮件
$ echo "Hello" | mail -s "Reply" [email protected]
$ exit
logout
切换到redhat用户,查看发现有邮件
# su - redhat
$ mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/spool/mail/redhat": 1 message 1 new
>N  1 [email protected]      Mon Jul  9 12:16  14/420   "Reply"
& 1
Message 1:
From [email protected]  Mon Jul  9 12:16:37 2012
X-Original-To: [email protected]
Delivered-To: [email protected]
To: [email protected]
Subject: Reply
Date: Mon,  9 Jul 2012 12:16:37 +0800 (CST)
From: [email protected]
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,也可以指定为其他的邮箱如 [email protected]
jerry:          tom 
加载信息
# postalias /etc/aliases
# service postfix reload

发送邮件
# su - redhat
$ echo "redhat to jerrry " | mail -s "Test" [email protected]

# su - tom
$ mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/spool/mail/tom": 1 message 1 new
>N  1 [email protected]      Mon Jul  9 15:04  14/428   "Test"
& 1
Message 1:
From [email protected]  Mon Jul  9 15:04:57 2012
X-Original-To: [email protected]
Delivered-To: [email protected]
Subject: Test
Date: Mon,  9 Jul 2012 15:04:57 +0800 (CST)
redhat to jerrry
&
可以发现有邮件了

你可能感兴趣的:(邮件别名,postfix安装)