1.创建运行用户和组
1)yum -y install cyrus-sasl-devel* cyrus-sasl-plain* cyrus-sasl-lib* cyrus-sasl-2.1* //安装SASL加密软件包
2)/etc/init.d/postfix stop && chkconfig --level 35 postfix off //将系统自带服务停止并开机禁用
3)gpasswd -a postfix postfix //将postfix用户加入到Postfix组
4)gpasswd -a postfix postdrop //将postfix用户加入到postdrop组
2.解压并安装postfix
1)tar -zxvf postfix-3.2.2.tar.gz -C /usr/src/
2)cd /usr/src/postfix-3.2.2/
3)make makefiles 'CCARGS=-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I /usr/include/sasl' 'AUXLIBS=-L/usr/lib64/sasl2 -lsasl2'
//生成Mailfile配置文件,并启动sasl认证、指定依赖库文件位置
//CCARGS:启用SASL认证,并指定SASL头文件存储位置
//AUXLIBS:指定额外的函数库文件位置
4)make && make install
3.编辑配置文件
1)postconf -n >/tmp/hehe.conf //将有效的配置文件导出
2)mv /tmp/hehe.conf /etc/postfix/main.cf
3)vim /etc/postfix/main.cf
9 inet_interfaces = 192.168.1.10 //指定监听IP
10 myhostname = mail.xueluo.org //新增,指定当前主机名
11 mydomain = xueluo.org //新增,指定邮件域
12 myorigin = $mydomain //新增,外发邮件时发送中邮件域
13 home_mailbox = Maildir/ //新增,邮件的存储位置(存储到用户的家目录)
19 mydestination = $myhostname,$mydomain //允许投递的目标邮件域
4)postfix start //启动postfix服务
SMTP邮件测试
1)groupadd mailusers //新建用户组
2)useradd -s /sbin/nologin -g mailusers hehe
3)useradd -s /sbin/nologin -g mailusers haha
4)echo "123" | passwd --stdin hehe
5)echo "123" | passwd --stdin haha
6)yum -y install telnet //安装远程连接工具
7)telnet mail.xueluo.org 25 //连接到邮件服务器的25端口
HELO mail.xueluo.org //宣告客户端地址
MAIL FROM:hehe@xueluo.org //告知发件人地址
RCPT TO:haha@xueluo.org //告知收件人地址
DATA //告知要发送的邮件数据
Subject: He is he //指定邮件标题
heh is hehe ~~~~!!! //撰写邮件正文
.quit //邮件编写完毕并退出
quit //退出连接
8)ls /home/haha/Maildir/new/ //查看是否有新邮件