一,安装:
[root@station10 ~]# yum install -y postfix
二,postconf工具介绍
Display defaults: postconf -d
Display current non-default settings: postconf -n
Modify main.cf:postconf -e key=value
Show supported map types: postconf -m
三,Incomming Postfix Configuration
修改/etc/postfix/main.cf文件
1,监听所有端口:
inet_interfaces = all
2,specify each name and alias by which the server may be referred (监听主机)
mydestination = $myhostname,localhost,mydomain,localhot,$mydomain
3,把默认的配置inet_interfaces = localhost 修改成:
inet_interfaces = all
4,监听主机默认可以不用改。
四,outgoing postfix configuration
配置/etc/postfix/main.cf文件
myorigin = $mydomain
masquerade_exceptions = root
此次配置成:
myorigin = $myhostname
masquerade_exceptions = root
测试上面两步:
5,station10用的是postfix发送到邮件,station12是用sendmail接收的。
station10发送邮件:
[root@station10 ~]# mail [email protected]
Subject: test
postfix
.
Cc:
[root@station10 ~]#
station12接收邮件:
[root@station12 ~]# mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/root": 1 message 1 new
>N 1 [email protected] Wed Oct 22 08:13 15/629 "test"
& 1
Message 1:
From [email protected] Wed Oct 22 08:13:25 2008
To: [email protected]
Subject: test
Date: Wed, 22 Oct 2008 01:00:25 +0800 (CST)
From: [email protected] (root)
postfix
& q
Saved 1 message in mbox
[root@station12 ~]#
6,更改outgoing postfix 配置:
此次配置成:
myorigin = $mydomain
masquerade_exceptions = root
测试发送:
[root@station10 ~]# mail [email protected]
Subject: test
myorigin
.
Cc:
[root@station10 ~]#
接收查看信息:
[root@station12 ~]# mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/root": 1 message 1 new
>N 1 [email protected] Wed Oct 22 08:19 15/600 "test"
& 1
Message 1:
From [email protected] Wed Oct 22 08:19:01 2008
To: [email protected]
Subject: test
Date: Wed, 22 Oct 2008 01:06:00 +0800 (CST)
From: [email protected] (root)
myorigin
& q
Saved 1 message in mbox
[root@station12 ~]#
五,inbound postfix aliases
1,本地别名配置和sendmail配置一样,都是修改/etc/aliases文件
如果让修改直接生效,执行:
[root@station10 ~]# postalias /etc/aliases
2,虚拟配置:
(1),编辑/etc/postfix/mail.cf文件
virtual_alias_maps = hash:/etc/postfix/virtual
(2),/etc/postfix/mail.cf的格式和sendmail一样
(3),rehash the file: postmap /etc/postfix/virtual
3, 实际配置:
(1),在/etc/postfix/mail.cf文件末尾添加:
virtual_alias_maps = hash:/etc/postfix/virtual
(2), 在/etc/postfix/virtual文件末尾添加:
[email protected] [email protected]
(3),[root@station10 ~]# postmap /etc/postfix/virtual
4, 测试:
本地别名测试:
[root@station10 ~]# mail xxx
Subject: test
send to xxx
.
Cc:
[root@station10 ~]# mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/root": 1 message 1 unread
>U 1 [email protected] Wed Oct 22 01:34 15/487 "test"
& 1
Message 1:
From [email protected] Wed Oct 22 01:34:57 2008
X-Original-To: xxx
Delivered-To: [email protected]
To: [email protected]
Subject: test
Date: Wed, 22 Oct 2008 01:34:57 +0800 (CST)
From: [email protected] (root)
send to xxx
& q
Saved 1 message in mbox
[root@station10 ~]#
虚拟别名测试:
[root@station10 ~]# mail [email protected]
Subject: test
send to station10.example.com
.
Cc:
[root@station10 ~]#
在另外一台机器上收到邮件:
[root@station12 ~]# mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/root": 2 messages 2 new
>N 1 [email protected] Wed Oct 22 08:43 15/609 "test"
N 2 [email protected] Wed Oct 22 08:49 15/651 "test"
& 2
Message 2:
From [email protected] Wed Oct 22 08:49:10 2008
To: [email protected]
Subject: test
Date: Wed, 22 Oct 2008 01:36:09 +0800 (CST)
From: [email protected] (root)
send to station10.example.com
& q
Saved 1 message in mbox
Held 1 message in /var/spool/mail/root
[root@station12 ~]#
六,outbound address rewriting
1, Enable in /etc/postfix/main.cf
smtp in the key name indicates SMTP only (not LMTP)
smtp_generic_maps = hash:/etc/postfix/generic
2, define in /etc/postfix/generic
[email protected] [email protected]
[email protected] [email protected]
3,Rehash the file: postmap /etc/postfix/generic
测试:
[root@station10 ~]# mail [email protected]
Subject: test
from to station12.example.com
.'
.
Cc:
[root@station10 ~]#
[root@station12 ~]# mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/root": 2 messages 1 new 2 unread
U 1 [email protected] Wed Oct 22 08:43 16/619 "test"
>N 2 [email protected] Wed Oct 22 09:04 16/621 "test"
& 2
Message 2:
From [email protected] Wed Oct 22 09:04:55 2008
To: [email protected]
Subject: test
Date: Wed, 22 Oct 2008 01:51:53 +0800 (CST)
From: [email protected] (root)
from to station12.example.com
.'
& q
Saved 1 message in mbox
Held 1 message in /var/spool/mail/root
[root@station12 ~]#
七,Postfix SMTP Restrictions
1,Create /etc/postfix/access
untagged version of Sendmail access file
rehash using postmap /etc/postfix/access
2,Edit main.cf
smtpd_TAG_restrictions =
check_TAG_access hash:/etc/postfix/access,...
TAG is one of sender,recipient,or client
Example:
smtpd_recipient_restrictions =
check_recipient_access hash:/etc/postfix/access,permit_mynetworks,reject_unauth_destination
八,postfix Operation
main.cf settings
Server names:mydestination must contain server's name and aliases
Listning interfaces:inet_interfaces = all
Archive all messages:always_bcc = address
View SMTP exchange: mail -v [email protected]
查看队列:postqueue -p
清空队列:postqueue -f
日志信息:tail -f /var/log/maillog
例子:
[root@station10 ~]# postqueue -p
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
865B8306C9 101 Wed Oct 22 01:25:43 root
xxx
76670306C8 156 Wed Oct 22 01:24:15 root
[email protected]
-- 0 Kbytes in 2 Requests.
[root@station10 ~]# postqueue -f
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/312079/viewspace-1012222/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/312079/viewspace-1012222/