mahonglin123456 发表于 2018-5-12 09:29:29

RedHat 5.4下构建postfix全功能电子邮(三)

  RedHat 5.4下构建postfix全功能电子邮(三)-安装并配置postfix软件
  三、安装postfix软件
3.1、卸载sendmail
sendmail将占用tcp 25端口,和postfix冲突:
# rpm -e sendmail --nodeps
3.2编译安装postfix软件
# groupadd -g 1200 postdrop
# groupadd -g 1000 postfix
# useradd -M -u 1000 -g postfix -G postdrop
-s /sbin/nologin postfix
# cd /soft
# tar -zxvf postfix-2.8.2.tar.gz -C /usr/local/src/
# cd /usr/local/src/postfix-2.8.2/
#安装,安装过程中会出现互动提问,直接选择默认设置即可.若配置中时出现问
#题,检查路径是否正确,或查看日志,和postfix用户是否存在
# make -f Makefile.init makefiles
'CCARGS=-DHAS_MYSQL
-I/usr/local/mysql/include/mysql
-DUSE_SASL_AUTH -I/usr/local/include/sasl'
'AUXLIBS=-L/usr/local/mysql/lib/mysql -lmysqlclient
-lz -lm -L/usr/local/lib -lsasl2'
# make
# make install
#生成别名二进制文件,这个步骤如果忽略,会造成postfix效率极低:
# newaliases
#查看postfix支持的模块是否有mysql;
#若不存在mysql,就不要往下做了,必须重做,知道出现mysql为止
# postconf –m



四、配置postfix
#进行一些基本配置,测试启动postfix并进行发信
# cp /etc/postfix/main.cf /etc/postfix/main.cf.bak
# vim /etc/postfix/main.cf
76 myhostname = mail.shuiyong.com
83 mydomain = shuiyong.com
99 myorigin = $mydomain
113 inet_interfaces = all
162 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
163 mail.$mydomain, www.$mydomain, ftp.$mydomain
260 mynetworks = 10.20.5.0/24, 127.0.0.0/8
说明:myorigin参数用来指明发件人所在的域名;mydestination参数指定postfix接收邮件时收件人的域名,即您的postfix系统要接收到哪个域名的邮件;myhostname 参数指定运行postfix邮件系统的主机的主机名,默认情况下,其值被设定为本地机器名;mydomain参数指定您的域名,默认情况下,postfix将myhostname的第一部分删除而作为mydomain的值;mynetworks 参数指定你所在的网络的网络地址,postfix系统根据其值来区别用户是远程的还是本地的,如果是本地网络用户则允许其访问;inet_interfaces 参数指定postfix系统监听的网络接口.注意:1、在postfix的配置文件中,参数行和注释行是不能处在同一行中的;2、任何一个参数的值都不需要加引号,否则,引号将会被当作参数值的一部分来使用;3、每修改参数及其值后执行 postfix reload 即可令其生效; 但若修改了inet_interfaces,则需重新启动postfix;4、如果一个参数的值有多个,可以将它们放在不同的行中, 只需要在其后的每个行前多置一个空格即可; postfix会把第一个字符为空格或tab的文本行视为上一行的延续;
#检查配置,启动postfix
# postfix start
postfix/postfix-script: starting the Postfix mail system
# postfix check
# service postfix restart
postfix: unrecognized service
#无法启动,此时要制作制作postfix启动控制文件
#【没有启动文件的启动postfix方法:
#/usr/local/postfix/sbin/postfix start】
# mkdir /tmp/abc
# cd /tmp/abc
#
cp /media/RHEL_5.4\i386\DVD/Server/postfix-2.3.3-2.1.el5_2.i386.rpm ./
# rpm2cpio postfix-2.3.3-2.1.el5_2.i386.rpm |cpio -id
16333 blocks
# ll
# ll etc/rc.d/init.d/postfix
# ll etc/rc.d/init.d/postfix
-rwxr-xr-x 1 root root 2404 Oct 15 14:19 etc/rc.d/init.d/postfix
# cp etc/rc.d/init.d/postfix /etc/rc.d/init.d/
# service postfix restart
Shutting down postfix: [ OK ]
Starting postfix: [ OK ]
# chkconfig --add postfix
# chkconfig postfix on
# chkconfig --list postfix
postfix    0:off1:off2:on   3:on   4:on   5:on   6:off
#连接postfix,验正服务启动状况,测试是否可以发信:
# useradd user1
# useradd user2
# echo "123" |passwd --stdin user1
# echo "123" |passwd --stdin user2
# telnet mail.shuiyong.com 25
Trying 10.20.5.35...
Connected to mail.shuiyong.com (10.20.5.35).
Escape character is '^]'.
220 mail.shuiyong.com ESMTP Postfix
ehlo mail.shuiyong.com
250-mail.shuiyong.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:user1@shuiyong.com
250 2.1.0 Ok
rcpt to:user2@shuiyong.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
user1--to--user2
.
250 2.0.0 Ok: queued as 4961D16DE6E
quit
221 2.0.0 Bye
Connection closed by foreign host.
# su - user2
$ mail
Mail version 8.1 6/6/93. Type ? for help.
&quot;/var/spool/mail/user2&quot;: 1 message 1 new
>N 1 user1@ shuiyong.com Tue oct 15 16:37 13/472
& 1
Message 1:
From user1@ shuiyong.com Tue oct 15 16:37:23 2012
X-Original-To: user2@shuiyong.com
Delivered-To: user2@ shuiyong.com
Date: Tue, 10 Apr 2012 16:36:42 +0800 (CST)
From: user1@shuiyong.com
user1--to--user2
& quit
Saved 1 message in mbox
$ cat /home/user2/mbox
页: [1]
查看完整版本: RedHat 5.4下构建postfix全功能电子邮(三)