安装Postfix // 这里我交所有软件打包成一个postfix.iso的文件,放入光驱中
确定系统里没有安装Sendmail,安装了卸载。
[root@mail ~]# rpm -qa sendmail
sendmail-8.13.8-8.el5
[root@mail ~]# rpm -e --nodeps sendmail
[root@mail ~]# rpm -qa sendmail
[root@mail ~]#
[root@mail ~]# groupadd -g 1200 postdrop
[root@mail ~]# groupadd -g 1000 postfix
[root@mail ~]# useradd -M -u 1000 -g postfix -G postdrop -s /sbin/nologin postfix
[root@mail ~]# yum -y install mysql-devel-* //挂载系统光盘安装安装mysql-devel-*,否则在后面会提示找不到mysql.h
[root@mail ~]# mount /dev/cdrom /mnt
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@mail ~]# cd /mnt
[root@mail mnt]# ll
[root@mail mnt]# tar -zxvf postfix-2.8.2.tar.gz -C /usr/src/
[root@mail mnt]# cd /usr/src/postfix-2.8.2/
[root@mail postfix-2.8.2]# cp /usr/local/mysql/lib/* /usr/lib/ //复制Mysql的库文件,否则后面安装Postfix提示库文件找不到
[root@mail postfix-2.8.2]# make -f Makefile.init makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include -DUSE_SASL_AUTH -I/usr/local/include/sasl'
'AUXLIBS=-L/usr/local/mysql/lib -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2'
[root@mail postfix-2.8.2]#
[root@mail postfix-2.8.2]# make
[root@mail postfix-2.8.2]# make install
[root@mail postfix-2.8.2]# newaliases // 生成别名二进制文件,这个步骤如果忽略,会造成postfix效率极低
[root@mail postfix-2.8.2]# postconf -a //有Dovecot说明支持Dovecot验证
dovecot
[root@mail postfix-2.8.2]# postconf -m
btree
cidr
environ
hash
internal
mysql //有Mysql说明支持Mysql验证
nis
pcre
proxy
regexp
static
tcp
texthash
unix
[root@mail postfix-2.8.2]#
[root@www postfix-2.8.2]#
[root@www postfix-2.8.2]# cp /etc/postfix/main.cf /etc/postfix/main.cf.bak //将配置文件做一个备份
[root@www postfix-2.8.2]# vim /etc/postfix/main.cf
76 myhostname = mail.linuxidc.com
83 mydomain = linuxidc.com
99 myorigin = $mydomain
113 inet_interfaces = all
162 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain, $mydomain, ftp.$mydomain
259 mynetworks = 192.168.10.0/24, 127.0.0.0/8
[root@www postfix-2.8.2]# postfix start
postfix/postfix-script: starting the Postfix mail system
[root@www postfix-2.8.2]# postfix check
[root@www postfix-2.8.2]# service postfix restart //此时提示postfix: 未被识别的服务,那么下面我们来制作postfix的启动文件
[root@www postfix-2.8.2]# mkdir /tmp/postfix
[root@www postfix-2.8.2]# cd /tmp/postfix/
[root@www postfix]# umount /mnt
[root@www postfix]# mount /dev/cdrom /mnt
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@www postfix]# cp /mnt/Server/postfix-2.3.3-2.1.el5_2.i386.rpm ./
[root@www postfix]#
[root@www postfix]# ll
总计 3652
-r--r--r-- 1 root root 3734257 05-27 20:46 postfix-2.3.3-2.1.el5_2.i386.rpm
[root@www postfix]#
[root@www postfix]# rpm2cpio postfix-2.3.3-2.1.el5_2.i386.rpm |cpio -id
16333 blocks
[root@www postfix]# ll
总计 3664
drwxr-xr-x 5 root root 4096 05-27 20:47 etc
-r--r--r-- 1 root root 3734257 05-27 20:46 postfix-2.3.3-2.1.el5_2.i386.rpm
drwxr-xr-x 7 root root 4096 05-27 20:47 usr
drwxr-xr-x 3 root root 4096 05-27 20:47 var
[root@www postfix]# ll etc/rc.d/init.d/
总计 4
-rwxr-xr-x 1 root root 2404 05-27 20:47 postfix
[root@www postfix]# cp etc/rc.d/init.d/postfix /etc/rc.d/init.d/
[root@www postfix]# service postfix restart
关闭 postfix: [确定]
启动 postfix: [确定]
[root@www postfix]#
[root@www postfix]# chkconfig --add postfix
[root@www postfix]# chkconfig postfix on
[root@www postfix]# chkconfig --list postfix
postfix 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
[root@www postfix]#
[root@www postfix]# useradd user1 //增加两个用户用于后面测试
[root@www postfix]# useradd user2
[root@www postfix]# echo "123456" |passwd --stdin user1 //给user1赋值初始密码
Changing password for user user1.
passwd: all authentication tokens updated successfully.
[root@www postfix]# echo "123456" |passwd --stdin user2
Changing password for user user2.
passwd: all authentication tokens updated successfully.
[root@www postfix]#
[root@www postfix]# service mysqld restart
Shutting down MySQL. [确定]
Starting MySQL.. [确定]
[root@www postfix]# service named restart
停止 named: [确定]
启动 named: [确定]
[root@www postfix]# //下面来进行telnet smtp的25号端口进行测试能否进行发送邮件
[root@www postfix]# telnet mail.linuxidc.com 25
Trying 192.168.10.170...
Connected to mail.linuxidc.com (192.168.10.170).
Escape character is '^]'.
220 mail.linuxidc.com ESMTP Postfix
ehlo mail.linuxidc.com
250-mail.linuxidc.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:user1@linuxidc.com //从user1发往到user2,这个过程测试成功说明可以正常发送邮件。
250 2.1.0 Ok
rcpt to:user2@linuxidc.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
this is a test E-mail,user1 to user2
.
250 2.0.0 Ok: queued as 80546275AA5
quit
221 2.0.0 Bye
Connection closed by foreign host.
[root@www postfix]#
[root@www postfix]#/检查user2是否收到
[root@www postfix]# su - user2
[user2@www ~]$ mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/user2": 1 message 1 new
>N 1 user1@linuxidc.com Sun May 27 20:59 13/500 //这里user2收到一封来自user1的邮件,序号为1
& 1
Message 1:
From user1@linuxidc.com Sun May 27 20:59:38 2012
X-Original-To: user2@linuxidc.com
Delivered-To: user2@linuxidc.com
Date: Sun, 27 May 2012 20:58:04 +0800 (CST)
From: user1@linuxidc.com
this is a test E-mail,user1 to user2 //刚才测试的内容
& quit
Saved 1 message in mbox
[user2@www ~]$
[user2@www ~]$ su - root /切换回root用户,在此处一定要加上 - 否则root的shell环境不一样。
口令:
[root@www ~]#