Postfix
前 言
在CentOS中,默认的邮件服务器(SMTP方面)是sendmail,但sendmail有若干的缺点,比如,配置 复杂、安全漏洞曾被多次发现–并且依然存在隐患、邮件发送速度慢等等,这里就不再一一叙述。而另一个被广泛应用于邮件服务方面的“Postfix”的缺点 就少得多,或者说它就是针对于sendmail的缺点,而被设计的。对应sendmail的短处,它在各方面也比较成熟。所以,无特殊要求,这里不推荐用 sendmail来构建邮件服务器。本站介绍的邮件服务器配置方法,也将基于Postfix。
添加MX记录(这里假设使用动态域名)
由于MX记录添加后,可能生效要等待一段时间(通常为数分钟或数十分钟,也可能马上生效),所以在安装配置前,我们首先为动态域名添加MX记录。添加方法也会因域名ISP的不同而不同,但大致信息如下:
mx mail.centospub.com. 10
a mail 服务器的IP地址
mail为别名,10为优先度。这个别名指向服务器的IP地址。(如有疑问或需要帮忙请到 技术论坛 发贴。)
确认MX记录的添加是否生效的方法:
[root@sample ~]# host -t mx centospub.com
centospub.com mail is handled by 10 mail.centospub.com. ← 确认MX记录生效
安装Postfix
然后,安装Postfix。
[root@sample ~]# yum -y install postfix ← 在线安装Postfix
Setting up Install Process
Setting up repositories
dag 100% |=========================| 1.1 kB 00:00
update 100% |=========================| 951 B 00:00
base 100% |=========================| 1.1 kB 00:00
addons 100% |=========================| 951 B 00:00
extras 100% |=========================| 1.1 kB 00:00
Reading repository metadata in from local files
primary.xml.gz 100% |=========================| 28 kB 00:04
update : ################################################## 84/84
Added 84 new packages, deleted 1499 old in 3.44 seconds
primary.xml.gz 100% |=========================| 157 B 00:00
Added 0 new packages, deleted 1499 old in 1.97 seconds
primary.xml.gz 100% |=========================| 26 kB 00:00
extras : ################################################## 102/102
Added 102 new packages, deleted 1499 old in 2.73 seconds
Reducing Dag RPM Repository for Red Hat Enterprise Linux to included packages only
Finished
Parsing package install arguments
Resolving Dependencies
–> Populating transaction set with selected packages. Please wait.
—> Downloading header for postfix to pack into transaction set.
postfix-2.2.10-1.RHEL4.2. 100% |=========================| 40 kB 00:00
—> Package postfix.i386 2:2.2.10-1.RHEL4.2 set to be updated
–> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
postfix i386 2:2.2.10-1.RHEL4.2 base 3.0 M
Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 3.0 M
Downloading Packages:
(1/1): postfix-2.2.10-1.R 100% |=========================| 3.0 MB 00:05
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: postfix ######################### [1/1]
Installed: postfix.i386 2:2.2.10-1.RHEL4.2
Complete!
配置Postfix及相关组件
[1] 对Postfix进行配置。
[root@sample ~]# vi /etc/postfix/main.cf ← 编辑Postfix的配置文件
#myhostname = host.domain.tld ← 找到此行,将等号后面的部分改写为主机名
↓
myhostname = sample.centospub.com ← 变为此状态,设置系统的主机名
#mydomain = domain.tld ← 找到此行,将等号后面的部分改写为域名
↓
mydomain = centospub.com ← 变为此状态,设置域名(我们将让此处设置将成为E-mail地址“@”后面的部分)
#myorigin = $mydomain ← 找到此行,将行首的#去掉
↓
myorigin = $mydomain ← 变为此状态,将发信地址“@”后面的部分设置为域名(非系统主机名)
inet_interfaces = localhost ← 找到此行,将“localhost”改为“all”
↓
下文链接:
http://blog.sina.com.cn/s/blog_62c4ea990102wb4r.html