设为首页 收藏本站
查看: 2993|回复: 6

[经验分享] Postfix+Dovecot+LAMP+Extmail搭建web邮件系统(二)

[复制链接]

尚未签到

发表于 2013-5-20 09:08:31 | 显示全部楼层 |阅读模式

一、邮件解决方案的软件组成:

二、DNS环境的搭建/配置:

三、LAMP环境的搭建:

四、Postfix 、Dovecot环境的搭建/配置

五、SMTP认证环境的搭建/配置

六、Maildrop的安装/配置

七、Extmail & Extman 环境的搭建/配置

八、trouble shooting

九、邮件收发测试


Postfix 、Dovecot环境的搭建/配置 :

编译安装Postfix:由于系统自带的Postfix不支持mysql扩展,因此需要自己编译安装



[Shell] 纯文本查看 复制代码
# service sendmail stop                 //关闭并卸载自带的sendmail服务
# rpm -e sendmail --nodeps
# rpm -ivh postfix-2.3.3-6.el5.src.rpm
# cd /usr/src/redhat/SPECS
# vi postfix.spec
%define LDAP 2
%define MYSQL 1                         //添加Mysql的支持(默认已注释)
%define PCRE 1
%define SASL 2
%define TLS 1
%define IPV6 1
%define POSTDROP_GID 90
%define PFLOGSUMM 1
# rpmbuild -bb postfix.spec
# cd ../RPMS/x86_64
# rpm -ivh postfix-2.3.3-6.x86_64.rpm
# vi /etc/postfix/main.cf
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
mail_owner = postfix
myhostname = mail.xfcy.org
mydomain = xfcy.org
myorigin = $mydomain
inet_interfaces = all
mydestination =
unknown_local_recipient_reject_code = 550
mynetworks = 192.168.0.0/24, 127.0.0.0/8
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
# chkconfig postfix on
# /etc/init.d/postfix start
Postfix邮件的外发测试:

[backcolor=white !important]
[backcolor=rgb(224, 224, 224) !important][size=1em]
[Shell] 纯文本查看 复制代码
# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 mail.xfcy.org ESMTP Postfix
ehlo mail.xfcy.org
250-mail.xfcy.org
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:root@xfcy.org
250 2.1.0 Ok
rcpt to:zyp19891128@163.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
subject:test
postfix test
.
250 2.0.0 Ok: queued as 5212B96E83
quit
221 2.0.0 Bye
Connection closed by foreign host.
# tailf /var/log/maillog
May 17 12:52:50 mail postfix/smtpd[15176]: connect from mail.xfcy.org[192.168.0.89]
May 17 12:53:04 mail postfix/smtpd[15176]: DF4B796E26: client=mail.xfcy.org[192.168.0.89]
May 17 12:53:15 mail postfix/cleanup[15210]: DF4B796E26: message-id=<[email]20130517045304.DF4B796E26@mail.xfcy.org[/email]>
May 17 12:53:15 mail postfix/qmgr[3050]: DF4B796E26: from=<[email]root@xfcy.org[/email]>, size=379, nrcpt=1 (queue active)
May 17 12:53:16 mail postfix/smtp[15214]: DF4B796E26: host 163mx03.mxmail.netease.com[220.181.14.159] said: 451 DT:SPM mx44, XsCowEBpUEu7t5VRWqdEAw--.1675S2, please try again 1368766395 [url]http://mail.163.com/help/help_sp[/url] ... x44&time=1368766395 (in reply to end of DATA command)
May 17 12:53:17 mail postfix/smtp[15214]: DF4B796E26: to=<[email]zyp19891128@163.com[/email]>, relay=163mx01.mxmail.netease.com[220.181.14.139]:25, delay=16, delays=14/0.02/1.6/0.24, dsn=2.0.0, status=sent (250 Mail OK queued as mx10,PMCowEBJElK8t5VRT8XKFQ--.914S2 1368766396)
May 17 12:53:17 mail postfix/qmgr[3050]: DF4B796E26: removed
May 17 12:53:23 mail postfix/smtpd[15176]: disconnect from mail.xfcy.org[192.168.0.89]




124131870.jpg


安装配置Dovecot:



[Shell] 纯文本查看 复制代码
# yum -y install dovecot
# vi /etc/dovecot.conf
mail_location = maildir:/var/maildata/domains/%d/%n/Maildir
auth default {
  mechanisms = plain
   #把pam { }这一项注释掉
  passdb sql {
    args = /etc/dovecot-mysql.conf
  }
  userdb passwd {
  }
  userdb sql {
        args =/etc/dovecot-mysql.conf
  }
  user = root
}
# vi /etc/dovecot-mysql.conf                                        //创建mysql认证文件
driver = mysql
connect = host=localhost dbname=extmail user=extmail password=extmail
default_pass_scheme = CRYPT
password_query = SELECT username AS user,password AS password FROM mailbox WHERE username ='%u'
user_query = SELECT maildir, uidnumber AS uid,gidnumber AS gid FROM mailbox WHERE username ='%u'
# chkconfig dovecot on
# /etc/init.d/dovecot start
# netstat -lntp | grep dovecot
tcp        0      0 :::993                      :::*                        LISTEN      5033/dovecot      
tcp        0      0 :::995                      :::*                        LISTEN      5033/dovecot      
tcp        0      0 :::110                      :::*                        LISTEN      5033/dovecot      
tcp        0      0 :::143                      :::*                        LISTEN      5033/dovecot
SMTP认证环境的搭建/配置:




[Shell] 纯文本查看 复制代码
配置cyrus-sasl认证:
# yum -y install cyrus-sasl
# postconf -a
cyrus
dovecot
# vi /etc/postfix/main.cf                   //为postfix开启基于cyrus-sasl的认证功能
##====================SASL========================
smtpd_recipient_restrictions =
        permit_mynetworks,
        permit_sasl_authenticated,
        reject_non_fqdn_hostname,
        reject_non_fqdn_sender,
        reject_non_fqdn_recipient,
        reject_unauth_destination,
        reject_unauth_pipelining,
        reject_invalid_hostname,
        reject_unknown_sender_domain,
        reject_unknown_recipient_domain
# SMTP sender login matching config
smtpd_sender_restrictions =
        permit_mynetworks,
        reject_sender_login_mismatch
# SMTP AUTH config here
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
# banner
mail_name = Postfix - by xfcy.org
smtpd_banner = Welcome to $myhostname ESMTP , $mail_name
# service postfix restart
# telnet localhost 25
Trying 192.168.0.89...
Connected to mail.xfcy.org (192.168.0.89).
Escape character is '^]'.
220 Welcome to mail.xfcy.org ESMTP , Postfix - by xfcy.org
ehlo mail.xfcy.org
250-mail.xfcy.org
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN                    //出现以下两行表示cyrus-sasl认证添加成功
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.
安装Courier-Authlib:
# tar jxvf courier-authlib-0.62.4.tar.bz2
# cd courier-authlib-0.62.4
# ./configure --prefix=/usr/local/courier-authlib --without-stdheaderdir --without-authuserdb --without-authpam --without-authldap --without-authpwd --without-authshadow --without-authvchkpw --without-authpgsql --without-authcustom --with-authmysql --with-redhat
# make
# make install
# make install-configure
# echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf
# ldconfig
# ldconfig -v | grep courier
/usr/local/courier-authlib/lib/courier-authlib:
        libcourierauthsasl.so -> libcourierauthsasl.so.0
        libcourierauthsaslclient.so -> libcourierauthsaslclient.so.0
        libcourierauth.so -> libcourierauth.so.0
        libcourierauthcommon.so -> libcourierauthcommon.so.0
# cp courier-authlib.sysvinit /etc/rc.d/init.d/courier-authlib
# chmod 755 /etc/rc.d/init.d/courier-authlib
# chkconfig --add courier-authlib
# chkconfig courier-authlib on
# chmod 755 /usr/local/courier-authlib/var/spool/authdaemon/
# cp /usr/local/courier-authlib/etc/authlib/authmysqlrc /usr/local/courier-authlib/etc/authlib/authmysqlrc.bak
# vi /usr/local/courier-authlib/etc/authlib/authmysqlrc
MYSQL_SERVER            127.0.0.1
MYSQL_USERNAME          extmail
MYSQL_PASSWORD          extmail
MYSQL_SOCKET            /var/lib/mysql/mysql.sock
MYSQL_PORT              3306
MYSQL_OPT               0
MYSQL_DATABASE          extmail
MYSQL_USER_TABLE        mailbox
MYSQL_CRYPT_PWFIELD     password
MYSQL_UID_FIELD         1000
MYSQL_GID_FIELD         1000
MYSQL_LOGIN_FIELD       username
MYSQL_HOME_FIELD        concat('/var/maildata/domains/',homedir)
MYSQL_NAME_FIELD        name
MYSQL_MAILDIR_FIELD     concat('/var/maildata/domains/',maildir)
# vi /usr/local/courier-authlib/etc/authlib/authdaemonrc
authmodulelist="authmysql"
authmodulelistorig="authmysql"
daemons=10
authdaemonvar=/usr/local/courier-authlib/var/spool/authdaemon
DEBUG_LOGIN=0
DEFAULTOPTIONS=""
LOGGEROPTS=""
# service courier-authlib start
Starting Courier authentication services: authdaemond
# ps -ef | grep authdaemond | grep -v grep
root      9173     1  0 02:50 ?        00:00:00 /usr/local/courier-authlib/sbin/courierlogger-pid=/usr/local/courier-authlib/var/spool/authdaemon/pid -start /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      9174  9173  0 02:50 ?        00:00:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      9175  9174  0 02:50 ?        00:00:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      9176  9174  0 02:50 ?        00:00:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      9177  9174  0 02:50 ?        00:00:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      9178  9174  0 02:50 ?        00:00:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      9179  9174  0 02:50 ?        00:00:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      9180  9174  0 02:50 ?        00:00:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      9181  9174  0 02:50 ?        00:00:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      9182  9174  0 02:50 ?        00:00:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      9183  9174  0 02:50 ?        00:00:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      9184  9174  0 02:50 ?        00:00:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
# vi /usr/lib64/sasl2/smtpd.conf
pwcheck_method: authdaemond
log_level: 3
mech_list:PLAIN LOGIN
authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket
Maildrop的安装/配置:



[Shell] 纯文本查看 复制代码
# groupadd -g 1000 vgroup
# useradd -g 1000 -u 1000 -s /sbin/nologin -M vuser
# tar jxvf maildrop-2.2.0.tar.bz2
# cd maildrop-2.2.0/
# ./configure --enable-sendmail=/usr/sbin/sendmail --enable-trusted-users='root vuser' --enable-syslog=1 --enable-maildirquota --enable-maildrop-uid=1000 --enable-maildrop-gid=1000 --with-trashquota --with-dirsync
# make && make install
# vi /etc/postfix/master.cf
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vuser argv=/usr/local/bin/maildrop -w 90 -d ${user}@${nexthop} ${recipient} ${user} ${extension} {nexthop}
//flags前面有"两个空格"
# vi /etc/postfix/main.cf
maildrop_destination_recipient_limit = 1
# maildrop -v                                                   //测试maildrop对authlib支持
maildrop 2.1.0 Copyright 1998-2005 Double Precision, Inc.
GDBM/DB extensions enabled.
Maildir quota extension enabled.
This program is distributed under the terms of the GNU General Public
License. See COPYING for additional information.
如果maildrop使用RPM包安装时,会自动创建vuser用户及vgroup用户组,专门用于邮件的存储,vuser:vgroup的uid/gid都是1000,这与一般的邮件文档中提及用postfix用户存邮件不一样。因为postfix用户的uid一般都低于500,而Suexec模块编译时对UID/GID的要求是要大于500,因此使用postfix用户不能满足要求。其次,如果用Maildrop作为投递代理(MDA),以postfix身份投递的话,会导致postfix MTA错误。



运维网声明 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-6029-1-1.html 上篇帖子: Postfix+Dovecot+LAMP+Extmail搭建web邮件系统(一) 下篇帖子: Postfix+Dovecot+LAMP+Extmail搭建web邮件系统(三) 搭建 web 邮件系统

尚未签到

发表于 2013-5-23 04:36:43 | 显示全部楼层
解释就系掩饰,掩饰等于无出色,无出色不如回家休息!!!

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

尚未签到

发表于 2013-5-28 04:22:15 | 显示全部楼层
不要在一棵树上吊死,在附近几棵树上多试试死几次~

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

尚未签到

发表于 2013-6-2 11:06:24 | 显示全部楼层
男人靠的住,母猪能上树!

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

尚未签到

发表于 2013-6-4 16:34:54 | 显示全部楼层
解释就系掩饰,掩饰等于无出色,无出色不如回家休息!!!

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

尚未签到

发表于 2013-6-5 07:27:46 | 显示全部楼层
沙发!沙发!

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

尚未签到

发表于 2013-6-5 16:25:42 | 显示全部楼层
生活***好玩,因为生活老***玩我!

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

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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