postfix安装和简单配置

一,安装:
[root@station10 ~]# yum install -y postfix

[@more@]

二,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 root@station12.example.com
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 root@station10.examp Wed Oct 22 08:13 15/629 "test"
& 1
Message 1:
From root@station10.example.com Wed Oct 22 08:13:25 2008
To: root@station12.example.com
Subject: test
Date: Wed, 22 Oct 2008 01:00:25 +0800 (CST)
From: root@station10.example.com (root)

postfix

& q
Saved 1 message in mbox
[root@station12 ~]#

6,更改outgoing postfix 配置:
此次配置成:
myorigin = $mydomain
masquerade_exceptions = root

测试发送:
[root@station10 ~]# mail root@station12.example.com
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 root@example.com Wed Oct 22 08:19 15/600 "test"
& 1
Message 1:
From root@example.com Wed Oct 22 08:19:01 2008
To: root@station12.example.com
Subject: test
Date: Wed, 22 Oct 2008 01:06:00 +0800 (CST)
From: root@example.com (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文件末尾添加:
root@station10.example.com root@station12.example.com
(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 root@station10.examp Wed Oct 22 01:34 15/487 "test"
& 1
Message 1:
From root@station10.example.com Wed Oct 22 01:34:57 2008
X-Original-To: xxx
Delivered-To: xxx@station10.example.com
To: xxx@station10.example.com
Subject: test
Date: Wed, 22 Oct 2008 01:34:57 +0800 (CST)
From: root@station10.example.com (root)

send to xxx

& q
Saved 1 message in mbox
[root@station10 ~]#

虚拟别名测试:
[root@station10 ~]# mail root@station10.example.com
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 root@example.com Wed Oct 22 08:43 15/609 "test"
N 2 root@station10.examp Wed Oct 22 08:49 15/651 "test"
& 2
Message 2:
From root@station10.example.com Wed Oct 22 08:49:10 2008
To: root@station10.example.com
Subject: test
Date: Wed, 22 Oct 2008 01:36:09 +0800 (CST)
From: root@station10.example.com (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

root@station10.example.com root@redhat.com
tapeback@station10.example.com tapeback.lastname@station10.example.com

3,Rehash the file: postmap /etc/postfix/generic


测试:
[root@station10 ~]# mail root@station12.example.com
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 root@example.com Wed Oct 22 08:43 16/619 "test"
>N 2 root@redhat.com Wed Oct 22 09:04 16/621 "test"
& 2
Message 2:
From root@redhat.com Wed Oct 22 09:04:55 2008
To: root@station12.example.com
Subject: test
Date: Wed, 22 Oct 2008 01:51:53 +0800 (CST)
From: root@redhat.com (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 user@domain.tld
查看队列: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
root@station10.example.com

-- 0 Kbytes in 2 Requests.
[root@station10 ~]# postqueue -f

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/312079/viewspace-1012222/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/312079/viewspace-1012222/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值