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

[经验分享] Centos6.4下配置邮件服务器postfix3.0.1(一)

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-6-26 08:51:23 | 显示全部楼层 |阅读模式
邮件服务器部署
1 编译安装postfix
www.postfix.org
①由于Centos已经有了postfix
1
2
[iyunv@localhost ~]# rpm -qa|grep postfix
postfix-2.6.6-2.2.el6_1.x86_64



所以得先卸载
1
[iyunv@localhost ~]# rpm -e postfix --nodeps



②从www.postfix.org获得源码安装包
③解压包
1
2
[iyunv@localhost ~]# tar xf postfix-3.0.1.tar.gz
[iyunv@localhost ~]# cd postfix-3.0.1



④安装前添加用户postfix,postdrop且使得依赖服务开机启动saslauthd
1
2
3
4
[iyunv@localhost ~]# groupadd -g 2525 postfix
[iyunv@localhost ~]# useradd -g 2525 -u 2525 -M -s /sbin/nologin postfix
[iyunv@localhost ~]# groupadd -g 2526 postdrop
[iyunv@localhost ~]# useradd -u 2526 -g 2526 -M -s /sbin/nologin postdrop



1
2
3
[iyunv@localhost ~]# service saslauthd start
Starting saslauthd:                                        [  OK  ]
[iyunv@localhost ~]# chkconfig saslauthd on



⑤编译安装
1
[iyunv@localhost postfix-3.0.1]# 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 -lrt -lm -L/usr/lib64/sasl2 -lsasl2   -lssl -lcrypto'



注意:
1 如果出现/usr/bin/ld: cannot find -lmysqlclient错误,请确保你的mysql路径库指定正确
2 如果出现 error while loading shared libraries: libpcre.so.1: cannot open shared object file: Error 40,请确保/usr/local/lib下有指向libpcre.so.0.0.1的链接,然后一定要ldconfig,我因为这个弄了半个小时
3 请确认每个文件夹你都可以查看到具体内容,如64为要修改为lib64
最终所有的互动都有默认值才成功
postfix: warning: smtputf8_enable is true, but EAI support is not compiled in

    Warning: you still need to edit myorigin/mydestination/mynetworks
    parameter settings in /etc/postfix/main.cf.

    See also http://www.postfix.org/STANDARD_CONFIGURATION_README.html
    for information about dialup sites or about sites inside a firewalled
    network.

    BTW: Check your /etc/aliases file and be sure to set up aliases
    that send mail for root and postmaster to a real person, then run
    /usr/bin/newaliases.
⑥为postfix提供SysV服务脚本/etc/rc.d/init.d/postfix,:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/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 $?






再为此脚本赋予执行权限:
1
2
[iyunv@www postfix]# vim /etc/rc.d/init.d/postfix
[iyunv@www postfix]# chmod +x /etc/rc.d/init.d/postfix




将postfix服务添加至服务列表:
1
[iyunv@www postfix-3.0.1]#chkconfig --add postfix




设置其开机自动启动:
# chkconfig postfix on
测试
[iyunv@www postfix]# service postfix restart
Shutting down postfix:                                     [  OK  ]
Starting postfix:                                          [  OK  ]

如果报错postfix: warning: smtputf8_enable is true, but EAI support is not compiled in,网上查得EAI是多语种,那么把smtpputf8_enable设置为no即可
1
2
[iyunv@www postfix-3.0.1]# postconf "smtputf8_enable = no"
[iyunv@www postfix-3.0.1]# postfix start



1
2
[iyunv@www postfix-3.0.1]# postfix start
postfix/postfix-script: starting the Postfix mail system



发现有25号端口在监听就ok
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[iyunv@www postfix-3.0.1]# netstat -tnpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:49198               0.0.0.0:*                   LISTEN      1604/rpc.statd      
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      1524/rpcbind        
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1810/sshd           
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      1665/cupsd         
tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      32725/master        
tcp        0      0 :::111                      :::*                        LISTEN      1524/rpcbind        
tcp        0      0 :::80                       :::*                        LISTEN      1834/httpd         
tcp        0      0 :::22                       :::*                        LISTEN      1810/sshd           
tcp        0      0 :::58038                    :::*                        LISTEN      1604/rpc.statd      
tcp        0      0 ::1:631                     :::*                        LISTEN      1665/cupsd         
tcp        0      0 :::3306                     :::*                        LISTEN      27743/mysqld



具体可以打开日志文件查看/var/log/maillog
然后
[iyunv@www postfix]# newaliases启动别名功能
2 配置邮件服务器
控制进程的:master.cf
主配置文件:main.cf
通常可以用postconf命令修改配置文件
postconf -d 显示默认的设置
postconf -n 显示修改的内容
postconf -m 支持的查找表模型
postconf -A 显示支持的SASL客户端插件类型
postconf -e PARAMETER=VALUE:更新值

smtp状态码:
1xx:纯信息
2xx:正确
3xx:操作尚未完成
4xx:暂时性错误
5xx:永久性错误

smtp协议命令:
helo(smtp)
ehlo(esmtp)
mail from:说明发件人
rcpt to:指定收件人
data


alias:邮件别名
/etc/aliases

默认情况下,postfix会为本地网段中继,具体配置见Centos6.4下配置邮件服务器postfix3.0.1(二)


运维网声明 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.yunweiku.com/thread-80600-1-1.html 上篇帖子: 获取或删除某个账户对所有其它账户的完全访问权限 下篇帖子: 邮件系统postfix 配置邮件 服务器
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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