Extmail邮件服务器centos搭建
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Extmail邮件服务器centos搭建相关的知识,希望对你有一定的参考价值。
接上一篇Extmail博文继续 https://www.aolens.cn/?p=1018
3.3 postfix开启基于cyrus-sasl的认证
查看sasl有关的安装包
[[email protected]mail ~]# rpm -qa |grep sasl
cyrus-sasl-md5-2.1.23-15.el6_6.2.x86_64
cyrus-sasl-2.1.23-15.el6_6.2.x86_64
cyrus-sasl-plain-2.1.23-15.el6_6.2.x86_64
cyrus-sasl-lib-2.1.23-15.el6_6.2.x86_64
cyrus-sasl-gssapi-2.1.23-15.el6_6.2.x86_64
cyrus-sasl-devel-2.1.23-15.el6_6.2.x86_64
3.3.1
postfix和sasl结合,编辑postfix配置文件
[[email protected] ~]# vim /etc/postfix/main.cf #添加一下配置 broken_sasl_auth_clients = yes smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_hostname,reject_unknown_sender_domain,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destination smtpd_sasl_auth_enable = yes smtpd_sasl_local_domain = $myhostname smtpd_sasl_security_options = noanonymous smtpd_banner = Welcome to our $myhostname SMTP [[email protected] ~]# service postfix restart 关闭 postfix: [确定] 启动 postfix: [确定] [[email protected] ~]# telnet 127.0.0.1 25 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is ‘^]‘. 220 Welcome to our mail.aolens.cn ESMTP,Warning: Version not Available! ehlo mail.aolens.cn 250-mail.aolens.cn 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-AUTH CRAM-MD5 DIGEST-MD5 PLAIN LOGIN GSSAPI 250-AUTH=CRAM-MD5 DIGEST-MD5 PLAIN LOGIN GSSAPI 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN
3.3.2 sasl配置
[[email protected] ~]# service saslauthd restart 停止 saslauthd: [确定] 正在启动 saslauthd: [确定] [[email protected] ~]# chkconfig --add saslauthd [[email protected] ~]# chkconfig saslauthd on
3.4 安装Courier authentication library
下载地址:http://www.courier-mta.org/download.html#authlib
[[email protected] ~]# tar jxf courier-authlib-0.66.4.tar.bz2 -C /usr/local/src/ [[email protected] ~]# cd /usr/local/src/courier-authlib-0.66.4/ [[email protected] /usr/local/src/courier-authlib-0.66.4]# ./configure --prefix=/usr/local/courier-authlib --sysconfdir=/etc --with-authmysql --with-mysql-libs=/usr/lib64/mysql --with-mysql-includes=/usr/include/mysql --with-RedHat --with-authmysqlrc=/etc/authmysqlrc --with-authdaemonrc=/etc/authdaemonrc --with-mailuser=postfix
报错:
configure: error: The Courier Unicode Library 1.2 appears not to be installed. You may need to install a separate development subpackage, in addition to the main package
下载:courier-unicode
https://sourceforge.net/projects/courier/files/courier-unicode/1.2/courier-unicode-1.2.tar.bz2/download
[[email protected] ~]# tar jxf courier-unicode-1.2.tar.bz2 [[email protected] ~]# cd courier-unicode-1.2 [[email protected] ~/courier-unicode-1.2]# ./configure [[email protected] ~/courier-unicode-1.2]# make && make install && echo 1
再次编译courier-authlib就好了
3.4.2 配置courier-authlib
[[email protected] /usr/local/src/courier-authlib-0.66.4]# chmod -R 755 /usr/local/courier-authlib/var/spool/authdaemon [[email protected] /usr/local/src/courier-authlib-0.66.4]# cp /etc/authdaemonrc.dist /etc/authdaemonrc [[email protected] /usr/local/src/courier-authlib-0.66.4]# cp /etc/authmysqlrc.dist /etc/authmysqlrc [[email protected] /usr/local/src/courier-authlib-0.66.4]# vim /etc/authdaemonrc #authmodulelist="authuserdb authpwd authshadow authmysql authcustom authpipe” #authmodulelistorig="authuserdb authpwd authshadow authmysql authcustom authpipe" authmodulelist="authmysql" authmodulelistorig="authmysql" MYSQL_SERVER localhost MYSQL_USERNAME root MYSQL_PASSWORD aolens MYSQL_SOCKET /var/lib/mysql/mysql.sock MYSQL_PORT 3306 MYSQL_DATABASE extmail MYSQL_USER_TABLE mailbox MYSQL_CRYPT_PWFIELD password DEFAULT_DOMAIN aolens.cn MYSQL_UID_FIELD ‘2525‘ MYSQL_GID_FIELD ‘2525‘ MYSQL_LOGIN_FIELD username MYSQL_HOME_FIELD concat(‘/var/mailbox/‘,homedir) MYSQL_MAILDIR_FIELD concat(‘/var/mailbox/‘,maildir) [[email protected] /usr/lib64/sasl2]# mkdir -pv /var/mailbox mkdir: 已创建目录 "/var/mailbox" [[email protected] /usr/lib64/sasl2]# chown -R postfix.postfix /var/mailbox
为courier-authlib创建启动脚本
[[email protected] /usr/local/src/courier-authlib-0.66.4]# cp courier-authlib.sysvinit /etc/init.d/courier-authlib [[email protected] /usr/local/src/courier-authlib-0.66.4]# chmod +x /etc/init.d/courier-authlib [[email protected] /usr/local/src/courier-authlib-0.66.4]# chkconfig --add courier-authlib [[email protected] /usr/local/src/courier-authlib-0.66.4]# chkconfig courier-authlib on [[email protected] /usr/local/src/courier-authlib-0.66.4]# echo "/usr/local/courier-authlib/lib/courier-authlib/" >> /etc/ld.so.conf.d/courier-authlib.conf [[email protected] /usr/local/src/courier-authlib-0.66.4]# ldconfig [[email protected] /usr/local/src/courier-authlib-0.66.4]# service courier-authlib startStarting Courier authentication services: authdaemond
3.4.3配置smtp以及虚拟用户的相关
创建smtpd.conf
pwcheck_method: authdaemond log_level: 3 mech_list: PLAIN LOGIN authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket
编辑main.cf
##postfix支持SMTP## broken_sasl_auth_clients = yes smtpd_client_restrictions = permit_sasl_authenticated smtpd_sasl_security_options = noanonymous smtpd_sasl_auth_enable = yes smtpd_sasl_local_domain = $myhostname smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination ##postfix支持虚拟用户## virtual_mailbox_base = /var/mailbox virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf virtual_alias_domains = virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf virtual_uid_maps = static:2525 virtual_gid_maps = static:2525 virtual_transport = virtual
3.5 导入数据库
使用extman源码目录下docs中的extmail.sql和init.sql建立数据库:
下载extmail 和extman
http://7xivyw.com1.z0.glb.clouddn.com/extmail-1.2.tar.gz
http://7xivyw.com1.z0.glb.clouddn.com/extman-1.1.tar.gz
[[email protected] ~/extman-1.1/docs]# cp mysql_virtual_* /etc/postfix/
创建数据库
[[email protected] ~/extman-1.1/docs]# mysql -uroot -p < extmail.sql [[email protected] ~/extman-1.1/docs]# mysql -uroot -p < init.sql [[email protected] ~/extman-1.1/docs]# service postfix restart 关闭 postfix: [确定] 启动 postfix: [确定]
3.6 配置dovecot
[[email protected] ~/extman-1.1/docs]# vim /etc/dovecot/conf.d/10-mail.conf #添加 mail_location = maildir:/var/mailbox/%d/%n/Maildir [[email protected] ~/extman-1.1/docs]# vim /etc/postfix/main.cf #添加 home_mailbox = Maildir/ [[email protected] /etc/dovecot/conf.d]# cp auth-sql.conf.ext auth-sql.conf [[email protected] /etc/dovecot/conf.d]# vim auth-sql.conf #修改 passdb { driver = sql #args = /etc/dovecot/dovecot-sql.conf.ext args = /etc/dovecot/dovecot-sql.conf } userdb { driver = sql #args = /etc/dovecot/dovecot-sql.conf.ext args = /etc/dovecot/dovecot-sql.conf }
创建dovecot-mysql.conf
[[email protected] /etc/dovecot/conf.d]# vim /etc/dovecot/dovecot-mysql.conf driver = mysql connect = host=localhost dbname=extmail user=root password=aolens 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‘ [[email protected] /etc/dovecot]# service dovecot start 正在启动 Dovecot Imap: [确定] [[email protected] /etc/dovecot]# chkconfig dovecot on
3.7 安装Extmail
[[email protected] ~]# tar zxf extmail-1.2.tar.gz [[email protected] ~]# cp -a extmail-1.2 /var/www/extsuite/extmail [[email protected] ~]# cd /var/www/extsuite/extmail [[email protected] /var/www/extsuite/extmail]# cp webmail.cf.default webmail.cf
3.7.2 修改主配置文件
SYS_MESSAGE_SIZE_LIMIT = 5242880 #用户可以发送的最大邮件 SYS_USER_LANG = zh_CN #语言选择 SYS_MAILDIR_BASE = /var/mailbox #邮件存放位置 SYS_MYSQL_USER = root #数据库配置 SYS_MYSQL_PASS = aolens SYS_MYSQL_DB = extmail SYS_MYSQL_HOST = localhost SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket
3.8安装extman
[[email protected] ~]# cp -a extman-1.1 /var/www/extsuite/extman [[email protected] /var/www/extsuite/extman]# cp webman.cf.default webman.cf [[email protected] /var/www/extsuite/extman]# chown -R postfix.postfix /var/www/extsuite/extman/cgi [[email protected] /var/www/extsuite/extman]# chown -R postfix.postfix /var/www/extsuite/extmail/cgi 为extman创建临时目录 [[email protected] /var/www/extsuite/extman]# mkdir /tmp/extman &&chown -R postfix.postfix /tmp/extman [[email protected] /var/www/extsuite/extman]# vim webman.cf SYS_CAPTCHA_ON = 0 #修改1为0 验证码功能 [[email protected] /var/www/extsuite/extman]# service postfix restart 关闭 postfix: [确定] 启动 postfix: [确定] [[email protected] /var/www/extsuite/extman]# service dovecot restart 停止 Dovecot Imap: [确定] 正在启动 Dovecot Imap: [确定] [[email protected] /var/www/extsuite/extman]# service saslauthd restart 停止 saslauthd: [确定] 正在启动 saslauthd: [确定]
3.9测试虚拟用户
[[email protected] ~]# /usr/local/courier-authlib/sbin/authtest -s login [email protected] extmail Authentication succeeded. Authenticated: [email protected] (uid 2525, gid 2525) Home Directory: /var/mailbox/extmail.org/postmaster Maildir: /var/mailbox/extmail.org/postmaster/Maildir/ Quota: (none) Encrypted Password: $1$phz1mRrj$3ok6BjeaoJYWDBsEPZb5C0 Cleartext Password: extmail Options: (none)
[email protected]时init.sql里自带的
4 安装perl依赖环境
extmail将会用到perl的Unix::syslogd功能,您可以去http://search.cpan.org搜索下载原码包进行安装。
[[email protected] ~]# tar zxf Unix-Syslog-1.0.tar.gz -C /usr/local/src/ [[email protected] ~]# cd /usr/local/src/Unix-Syslog-1.0/ [[email protected] /usr/local/src/Unix-Syslog-1.0]# perl Makefile.PL [[email protected] /usr/local/src/Unix-Syslog-1.0]# make && make install
4.2 配置apache虚拟主机
[[email protected] ~]# vim /etc/httpd/conf/httpd.conf User postfix Group postfix <VirtualHost *:80> ServerName mail.aolens.com DocumentRoot "/var/www/extsuite/extmail/html/" ScriptAlias /extmail/cgi /var/www/extsuite/extmail/cgi Alias /extmail /var/www/extsuite/extmail/html ScriptAlias /extman/cgi /var/www/extsuite/extman/cgi Alias /extman /var/www/extsuite/extman/html </VirtualHost> [[email protected] ~]# service httpd restart
访问mail.aolens.cn
选择登陆邮箱管理:默认的账号密码是:[email protected] extmail*123*
添加域,添加用户
使用普通用户登录
报错:
Can‘t chdir to /var/mailbox/aolens.cn/aolens/Maildir/, No such file or directory
[/shell][[email protected] /var/www/extsuite]# vim /var/www/extsuite/extman/webman.cf
SYS_MAILDIR_BASE = /var/mailbox
SYS_MYSQL_USER = root
SYS_MYSQL_PASS = aolens
SYS_MYSQL_DB = extmail
SYS_MYSQL_HOST = localhost
SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock[/shell]
就是因为webman.cf没有设置导致创建用户后没有自动创建用户邮件存放路径。
不启动cmdserver 的话系统页面会出现Connection refused
[[email protected] /var/www/extsuite/extman/daemon]# ./cmdserver -d
loaded ok
现在尝试发送邮件:
[email protected] —> [email protected] 邮件发送成功
[email protected] —> [email protected] 发送不成功
报错:
mail postfix/smtpd[6525]: NOQUEUE: reject: RCPT from localhost[127.0.0.1]: 550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in local recipient table; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<localhost.localdomain>
修改main.cf
mydestination = $myhostname
邮件发送成功!
本文出自 “aolens·程超” 博客,请务必保留此出处http://aolens.blog.51cto.com/7021142/1783878
以上是关于Extmail邮件服务器centos搭建的主要内容,如果未能解决你的问题,请参考以下文章