设为首页 收藏本站
查看: 4185|回复: 0

[经验分享] 邮件服务器之编译安装postfix

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-7-24 09:21:23 | 显示全部楼层 |阅读模式
                      安装环境:redhat5.8 2.6.18-194.el5 i386
mysql 5.6.25 (mysql> SELECT VERSION();)
安装前

关闭sendmail服务 service sendmail stop &&chkconfig sendmail off
安装gcc环境  yum -y install gcc+

确认开发环境已安装;
   Development Libraries
   Development Tools
启动mysqld数据库服务. service mysqld start

启动saslauthd服务 service saslauthd start
添加postsfix账户:groupadd -g 2525 postfix

useradd -g 2525 -u 2525 -s /sbin/nologin -M postfix
添加postdrop用户组 groupadd -g 2526 postdrop
useradd -g 2526 -u 2526 -s /sbin/nologin -M postdrop
开始安装postfix
3.解压源码包 tar xf postfix-2.10.8.tar.gz
2.进入解压后的文件夹执行:make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS ' 'AUXLIBS=-L/usr/local/mysql/lib -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2 -lssl -lcrypto'
  • 说明:
    -I/usr/local/mysql/include指明MySQl头文件路径
    AUXLIBS=-L/usr/local/mysql/lib指明MySQL库文件路径
    -DUSE_SASL_AUTH 启用SASL支持
    -I/usr/include/sasl 指明SASL头文件路径
    -DUSE_TLS支持SMTPS协议

makefile过程中可能遇到的错误:
    *** [alldig.o] 错误 127  缺少gcc环境
3.make **make install
    安装路径和一些安装时的配置说明:

   
install_root: [/] /
tempdir: [/root/postfix-2.10.8] /tmp/postfix 安装过程中的临时文件目录
config_directory: [] /etc/postfix    配置文件目录
command_directory: [] /usr/sbin    二进制文件目录
daemon_directory: [] /usr/libexec/postfix     
data_directory: [] /var/lib/postfix     
html_directory: [] /usr/local/apache/htdocs     html文件目录
mail_owner: [] postfix         
mailq_path: [] /usr/bin/mailq   
manpage_directory: [] /usr/local/man     man文件
newaliases_path: [] /usr/bin/newaliases     
queue_directory: [] /var/spool/postfix     
readme_directory: [] no     
sendmail_path: [] /usr/sbin/sendmail
setgid_group: [] postdrop   
make install过程中可能的错误:
    libpcre.so.1文件缺失 ln -s /usr/local/lib/libpcre.so.1 /lib

    libmysqlclient.so.18文件缺失 ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
4.提供SysV启动脚本

vi /ettc/init.d/postfix

#!/bin/bash
#
# postfix      Postfix Mail Transfer Agent
#
# chkconfig: 2345 80 30
# description: Postfix is a Mail Transport Agent, which is the program \
#              that moves mail from one machine to another.
# processname: master
# pidfile: /var/spool/postfix/pid/master.pid
# config: /etc/postfix/main.cf
# config: /etc/postfix/master.cf

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ $NETWORKING = "no" ] && exit 3

[ -x /usr/sbin/postfix ] || exit 4
[ -d /etc/postfix ] || exit 5
[ -d /var/spool/postfix ] || exit 6

RETVAL=0
prog="postfix"

start() {
# Start daemons.
echo -n $"Starting postfix: "
        /usr/bin/newaliases >/dev/null 2>&1
/usr/sbin/postfix start 2>/dev/null 1>&2 && success || failure $"$prog start"
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/postfix
        echo
return $RETVAL
}

stop() {
  # Stop daemons.
echo -n $"Shutting down postfix: "
/usr/sbin/postfix stop 2>/dev/null 1>&2 && success || failure $"$prog stop"
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/postfix
echo
return $RETVAL
}

reload() {
echo -n $"Reloading postfix: "
/usr/sbin/postfix reload 2>/dev/null 1>&2 && success || failure $"$prog reload"
RETVAL=$?
echo
return $RETVAL
}

abort() {
/usr/sbin/postfix abort 2>/dev/null 1>&2 && success || failure $"$prog abort"
return $?
}

flush() {
/usr/sbin/postfix flush 2>/dev/null 1>&2 && success || failure $"$prog flush"
return $?
}

check() {
/usr/sbin/postfix check 2>/dev/null 1>&2 && success || failure $"$prog check"
return $?
}

restart() {
stop
start
}

# See how we were called.
case "$1" in
  start)
start
;;
  stop)
stop
;;
  restart)
stop
start
;;
  reload)
reload
;;
  abort)
abort
;;
  flush)
flush
;;
  check)
check
;;
  status)
  status master
;;
  condrestart)
[ -f /var/lock/subsys/postfix ] && restart || :
;;
  *)
echo $"Usage: $0 {start|stop|restart|reload|abort|flush|check|status|condrestart}"
exit 1
esac

exit $?

# END
给予x权限 chmod +x /etc/init.d/postfix


将postfix加入服务列表:chkconfig --add postfix

postfix的配置文件
       master 核心进程,配置文件/etc/postfix/master.cf
        mail配置 /etc/postfix/main.cf
                参数 = 值:参数必须顶格写,以空白字符开头的行被认为是上一行的延续
smtp协议命令(原语)
    helo
    ehlo
    mail from:
    rcpt to
    data
    .
启动服务测试  service postfix start
[iyunv@localhost postfix-2.10.8]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 localhost.localdomain ESMTP Postfix
helo localhost

250 localhost.localdomain
mail from:obama@w.com
250 2.1.0 Ok
rcpt to:root
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
Subject:Are you ready?
hahhahaha
.
250 2.0.0 Ok: queued as C4DEA3F52D8
quit
221 2.0.0 Bye
Connection closed by foreign host.

                   


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-90068-1-1.html 上篇帖子: 邮件服务器客户端能发不能收,web访问收发正常 下篇帖子: 【Ex2013】【虚拟目录】owa虚拟目录创建失败 邮件服务器
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表