标签:perm 登陆 ado MF 5.5 base 编辑 tcl 3.2
Postfix dovecot Extmail 邮箱系统
早前的内部邮箱系统重新整理下,现在Extmail官方有集成镜像的EMOS_1.6_x86_64免费版;
系统环境: linux 6.7 x64 4G
hosts: 172.16.2.19 mail.18mail.com
一、准备 环境
简便的可以 yum 进行安装;安装 yum 源; rpm -ivh http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
1、环境的基础依赖包: yum install gcc gcc-c++ gdbm libtool-ltdl yum install cyrus-sasl-md5 perl-GD perl-DBD-MySQL perl-GD perl-CPAN perl-CGI perl-CGI-Session cyrus-sasl-lib cyrus-sasl-plain cyrus-sasl cyrus-sasl-devel libtool-ltdl-devel telnet mail libicu-devel 2、lamp 环境: yum -y install httpd mysql-server mysql mysql-devel php56w php56w-fpm php56w-mysql php56w-common php56w-gd php56w-mbstring php56w-mcrypt php56w-devel php56w-xml php56w-imap php56w-pear php56w-snmp
二、安装 postfix dovecot
yum install postfix -y 创建邮箱属于账户组: groupadd -g 5000 18mail useradd -g 18mail -u 5000 -s /sbin/nologin 18mail
1、配置 postfix :
postfix 的 需要更改的文件是 main.cf 和 master.cf 后面第六条会配置;
三、安装 dovecot
# yum install dovecot dovecot-devel dovecot-mysql pam-devel -y
四、安装 courier-authlib
1、courier-authlib 是需要 courier-unicode 依赖;
# wget https://sourceforge.net/projects/courier/files/courier-unicode/1.2/courier-unicode-1.2.tar.bz2 tar -jxvf 解压缩进行编译安装
# cd courier-unicode # ./configure # make && make install
2、先编译安装 courier-authlib:
# wget https://sourceforge.net/projects/courier/files/authlib/0.66.2/courier-authlib-0.66.2.tar.bz2 # tar -jxvf courier-authlib-0.66.2.tar.bz2
解压之后缩进行编译安装
# cd courier-authlib # ./configure --prefix=/usr/local/courier-authlib --sysconfdir=/etc --without-authpam --without-authshadow --without-authvchkpw --without-authpgsql --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=18mail # make && make install
3、配置 courier-authlib:
# chmod 755 /usr/local/courier-authlib/var/spool/authdaemon # cd /usr/local/courier-authlib/
拷贝 auth 验证文件:
# cp /etc/authdaemonrc.dist /etc/authdaemonrc # cp /etc/authmysqlrc.dist /etc/authmysqlrc
4、配置验证方式:这里只使用了 authmysql
# cat /etc/authdaemonrc |grep -v ^$ |grep -v ^# authmodulelist="authmysql" authmodulelistorig="authmysql" daemons=5 authdaemonvar=/usr/local/courier-authlib/var/spool/authdaemon DEBUG_LOGIN=0 DEFAULTOPTIONS="" LOGGEROPTS=""
5、配置验证存储信息 (邮箱的目录 数据存放库的名称 密码 以及自己的域名)
# cat /etc/authmysqlrc |grep -v ^$ |grep -v ^# MYSQL_SERVER localhost 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 uidnumber MYSQL_GID_FIELD gidnumber MYSQL_LOGIN_FIELD username MYSQL_HOME_FIELD homedir MYSQL_NAME_FIELD name MYSQL_MAILDIR_FIELD maildir MYSQL_QUOTA_FIELD quota MYSQL_SELECT_CLAUSE SELECT username,password,"",uidnumber,gidnumber, CONCAT(‘/home/18mail/‘,homedir), CONCAT(‘/home/18mail/‘,maildir), quota, name, CONCAT("disableimap=",disableimap,",disablepop3=", disablepop3,",disablewebmail=",disablewebmail, ",disablesmtpd=",disablesmtpd,",disablesmtp=", disablesmtp,",disablenetdisk=",disablenetdisk, ",netdiskquota=",netdiskquota) FROM mailbox WHERE username = ‘$(local_part)@$(domain)‘ DEFAULT_DOMAIN 18mail.com
6、courier-authlib 配置服务启动:
# cp courier-authlib.sysvinit /etc/init.d/courier-authlib # chmod +x /etc/init.d/courier-authlib # chkconfig --add courier-authlib # chkconfig courier-authlib on # echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf.d/courier-authlib.conf # ldconfig # service courier-authlib start
7、smtp以及虚拟用户相关的设置:
手动创建 smtpd.conf
# 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
五、安装 extmail
# wget http://7xivyw.com1.z0.glb.clouddn.com/extmail-1.2.tar.gz # wget http://7xivyw.com1.z0.glb.clouddn.com/extman-1.1.tar.gz
1、创建extmail 临时文件目录与session目录;并设置邮箱账户的用户组的权限;
# mkdir -p /tmp/extmail/upload # chown -R 18mail:18mail /tmp/extmail/ 同样的为 extman创建临时目录: # mkdir /tmp/extman # chown -R 18mail:18mail /tmp/extman/
2、在 http web创建extsuite 目录 ( 默认/var/www/ )
# mkdir -p /var/www/extsuite
解压缩 extmail extman 至 /var/www/extsuite 目录 更改 extmail 和 extman 下的 cgi目录的属主属组: # chown -R 18mail:18mail /var/www/extsuite/
3、配置 extmail 相关配置;
# cd /var/www/extsuite/extmail # cp -rp webmail.cf.default webmail.cf
更改 webmail.cf 配置
# cat /var/www/extsuite/extmail/webmail.cf |grep -v ^$ |grep -v ^# SYS_CONFIG = /var/www/extsuite/extmail/ SYS_LANGDIR = /var/www/extsuite/extmail/lang SYS_TEMPLDIR = /var/www/extsuite/extmail/html SYS_HTTP_CACHE = 0 SYS_SMTP_HOST = localhost SYS_SMTP_PORT = 25 SYS_SMTP_TIMEOUT = 5 SYS_SPAM_REPORT_ON = 0 SYS_SPAM_REPORT_TYPE = dspam SYS_SHOW_WARN = 0 SYS_IP_SECURITY_ON = 1 SYS_PERMIT_NOQUOTA = 1 SYS_SESS_DIR = /tmp/extmail SYS_UPLOAD_TMPDIR = /tmp/extmail/upload SYS_LOG_ON = 1 SYS_LOG_TYPE = syslog SYS_LOG_FILE = /var/log/extmail.log SYS_SESS_TIMEOUT = 0 SYS_SESS_COOKIE_ONLY = 1 SYS_USER_PSIZE = 10 SYS_USER_SCREEN = auto SYS_USER_LANG = zh_CN SYS_APP_TYPE = WebMail SYS_USER_TEMPLATE = default SYS_USER_CHARSET = utf-8 SYS_USER_TRYLOCAL = 1 SYS_USER_TIMEZONE = +0800 SYS_USER_CCSENT = 1 SYS_USER_SHOW_HTML = 1 SYS_USER_COMPOSE_HTML = 1 SYS_USER_CONV_LINK =1 SYS_USER_ADDR2ABOOK = 1 SYS_MESSAGE_SIZE_LIMIT = 5242880 SYS_MIN_PASS_LEN = 2 SYS_MFILTER_ON = 1 SYS_NETDISK_ON = 1 SYS_SHOW_SIGNUP = 1 SYS_DEBUG_ON = 1 SYS_AUTH_TYPE = mysql SYS_MAILDIR_BASE = /home/18mail SYS_AUTH_SCHEMA = virtual SYS_CRYPT_TYPE = md5crypt SYS_MYSQL_USER = extmail SYS_MYSQL_PASS = extmail SYS_MYSQL_DB = extmail SYS_MYSQL_HOST = localhost SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock SYS_MYSQL_TABLE = mailbox SYS_MYSQL_ATTR_USERNAME = username SYS_MYSQL_ATTR_DOMAIN = domain SYS_MYSQL_ATTR_PASSWD = password SYS_MYSQL_ATTR_CLEARPW = clearpwd SYS_MYSQL_ATTR_QUOTA = quota SYS_MYSQL_ATTR_NDQUOTA = netdiskquota SYS_MYSQL_ATTR_HOME = homedir SYS_MYSQL_ATTR_MAILDIR = maildir SYS_MYSQL_ATTR_DISABLEWEBMAIL = disablewebmail SYS_MYSQL_ATTR_DISABLENETDISK = disablenetdisk SYS_MYSQL_ATTR_DISABLEPWDCHANGE = disablepwdchange SYS_MYSQL_ATTR_ACTIVE = active SYS_MYSQL_ATTR_PWD_QUESTION = question SYS_MYSQL_ATTR_PWD_ANSWER = answer SYS_LDAP_BASE = o=extmailAccount,dc=example.com SYS_LDAP_RDN = cn=Manager,dc=example.com SYS_LDAP_PASS = secret SYS_LDAP_HOST = localhost SYS_LDAP_ATTR_USERNAME = mail SYS_LDAP_ATTR_DOMAIN = virtualDomain SYS_LDAP_ATTR_PASSWD = userPassword SYS_LDAP_ATTR_CLEARPW = clearPassword SYS_LDAP_ATTR_QUOTA = mailQuota SYS_LDAP_ATTR_NDQUOTA = netdiskQuota SYS_LDAP_ATTR_HOME = homeDirectory SYS_LDAP_ATTR_MAILDIR = mailMessageStore SYS_LDAP_ATTR_DISABLEWEBMAIL = disablewebmail SYS_LDAP_ATTR_DISABLENETDISK = disablenetdisk SYS_LDAP_ATTR_DISABLEPWDCHANGE = disablePasswdChange SYS_LDAP_ATTR_ACTIVE = active SYS_LDAP_ATTR_PWD_QUESTION = question SYS_LDAP_ATTR_PWD_ANSWER = answer SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket SYS_G_ABOOK_TYPE = file SYS_G_ABOOK_LDAP_HOST = localhost SYS_G_ABOOK_LDAP_BASE = ou=AddressBook,dc=example.com SYS_G_ABOOK_LDAP_ROOTDN = cn=Manager,dc=example.com SYS_G_ABOOK_LDAP_ROOTPW = secret SYS_G_ABOOK_LDAP_FILTER = objectClass=OfficePerson SYS_G_ABOOK_FILE_PATH = /var/www/extsuite/extmail/globabook.cf SYS_G_ABOOK_FILE_LOCK = 1 SYS_G_ABOOK_FILE_CONVERT = 0 SYS_G_ABOOK_FILE_CHARSET = utf-8
4、配置 extman 文件
# cd /var/www/extsuite/extmail # cp -rp webman.cf.default webman.cf
更改 extman.cf 配置
# cat /var/www/extsuite/extman/webman.cf |grep -v ^$ |grep -v ^# SYS_CONFIG = /var/www/extsuite/extman/ SYS_LANGDIR = /var/www/extsuite/extman/lang SYS_TEMPLDIR = /var/www/extsuite/extman/html SYS_MAILDIR_BASE = /home/18mail SYS_SHOW_WARN = 0 SYS_SESS_DIR = /tmp/extman/ SYS_CAPTCHA_ON = 1 SYS_CAPTCHA_KEY = r3s9b6a7 SYS_CAPTCHA_LEN = 6 SYS_PURGE_DATA = 0 SYS_PSIZE = 20 SYS_APP_TYPE = ExtMan SYS_TEMPLATE_NAME = default SYS_DEFAULT_EXPIRE = 1y SYS_GROUPMAIL_SENDER = postmaster@extmail.org SYS_DEFAULT_SERVICES = webmail,smtpd,smtp,pop3,netdisk SYS_ISP_MODE = no SYS_DOMAIN_HASHDIR = yes SYS_DOMAIN_HASHDIR_DEPTH = 2x2 SYS_USER_HASHDIR = yes SYS_USER_HASHDIR_DEPTH = 2x2 SYS_MIN_UID = 500 SYS_MIN_GID = 100 SYS_DEFAULT_UID = 1000 SYS_DEFAULT_GID = 1000 SYS_QUOTA_MULTIPLIER = 1048576 SYS_QUOTA_TYPE = courier SYS_DEFAULT_MAXQUOTA = 500 SYS_DEFAULT_MAXALIAS = 100 SYS_DEFAULT_MAXUSERS = 100 SYS_DEFAULT_MAXNDQUOTA = 500 SYS_USER_DEFAULT_QUOTA = 5 SYS_USER_DEFAULT_NDQUOTA = 5 SYS_USER_DEFAULT_EXPIRE = 1y SYS_BACKEND_TYPE = mysql SYS_CRYPT_TYPE = md5crypt SYS_MYSQL_USER = extman SYS_MYSQL_PASS = extmail SYS_MYSQL_DB = extmail SYS_MYSQL_HOST = localhost SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock SYS_MYSQL_TABLE = manager SYS_MYSQL_ATTR_USERNAME = username SYS_MYSQL_ATTR_PASSWD = password SYS_LDAP_BASE = dc=extmail.org SYS_LDAP_RDN = cn=Manager,dc=extmail.org SYS_LDAP_PASS = secret SYS_LDAP_HOST = localhost SYS_LDAP_ATTR_USERNAME = mail SYS_LDAP_ATTR_PASSWD = userPassword SYS_RRD_DATADIR = /var/lib SYS_RRD_TMPDIR = /tmp/viewlog SYS_RRD_QUEUE_ON = yes SYS_CMDSERVER_SOCK = /tmp/cmdserver.sock SYS_CMDSERVER_MAXCONN = 5 SYS_CMDSERVER_PID = /var/run/cmdserver.pid SYS_CMDSERVER_LOG = /var/log/cmdserver.log SYS_CMDSERVER_AUTHCODE = your_auth_code_here SYS_IGNORE_SERVER_LIST = web
5、extmail 数据库导入;
5.1 导入前需要更改两项配置;
my.cnf 取消 SSL 验证 ;不然会报 ‘ssl_cipher‘ 错?
# vi /etc/my.cnf
注释这一行;待数据导入之后再取消注释;
# sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
5.2 编辑 extmail.sql 数据库文件
msyql 数据库不能识别 TYPE=MyISAM,需要把TYPE=MyISAM 更改为 ENGINE=MyISAM
# sed -i ‘s/TYPE/ENGINE/g‘ /var/www/extsuite/extman/docs/extmail.sql
5.3 编辑 init.sql
可以把默认的域更改成自己域 (我自己的是 18mail.com)
# sed -i ‘s/extmail.org/18mail.com/g‘ /var/www/extsuite/extman/docs/init.sql
5.4 开始导入数据库;
mysql -u root -p < /var/www/extsuite/extman/docs/extmail.sql mysql -u root -p < /var/www/extsuite/extman/docs/init.sql
5.5 数据导入成功后 设置两个extmail 远程账户;
# mysql -uroot -p 进入数据库 设置extmail库 localhost远程账户
# /etc/init.d/msyqld start
> use extmail; > grant all on extmail.* to ‘extmail‘@‘%‘ identified by ‘extmail‘; > flush privilege;
> use extmail; > grant all on extmail.* to ‘extman‘@‘%‘ identified by ‘extmail‘; > flush privileges;
# chkconfig mysqld on
六、配置 postfix 结合 extmail;
1、拷贝 extmail 下的数据链接文件到 postfix 下
拷贝数据连接文件:
# mkdir /etc/postfix/sql
# cp -rp /var/www/extsuite/extman/docs/mysql_virtual_* /etc/postfix/sql
2、设置 postfix SMTP认证 和 虚拟账户;
2.1 配置 main.cf
# vi /etc/postfix/main.cf
queue_directory = /var/spool/postfix command_directory = /usr/sbin daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix mail_owner = postfix inet_interfaces = all inet_protocols = all myhostname = mail.18mail.com mydomain = 18mail.com myorigin = $mydomain # mydestination = $myhostname, localhost.$mydomain, localhost mydestination = mynetworks = 0.0.0.0/0 # 可以设置允许的网段访问 local_recipient_maps = unknown_local_recipient_reject_code = 550 alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases debug_peer_level = 2 debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5 sendmail_path = /usr/sbin/sendmail.postfix newaliases_path = /usr/bin/newaliases.postfix mailq_path = /usr/bin/mailq.postfix setgid_group = postdrop html_directory = no manpage_directory = /usr/share/man sample_directory = /usr/share/doc/postfix-2.6.6/samples readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES #启用SMTP认证 smtpd_sasl_auth_enable = yes smtpd_sasl_local_domain = $myhostname smtpd_sasl_type = dovecot smtpd_sasl_security_options = noanonymous smtpd_sasl_path = /var/spool/postfix/private/auth smtpd_banner = $myhostname ESMTP $mail_name smtpd_sender_restrictions = permit_mynetworks, reject_sender_login_mismatch, reject_authenticated_sender_login_mismatch, reject_unauthenticated_sender_login_mismatch smtpd_sasl_application_name = smtpd broken_sasl_auth_clients = yes smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination smtpd_sasl_security_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination smtpd_client_restrictions = permit_mynetworks,permit_sasl_authenticated smtpd_sender_login_maps = mysql:/etc/postfix/sql/mysql_virtual_sender_maps.cf, mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf #启用虚拟用户 virtual_mailbox_base = /home/18mail/ # 前面创建的邮件18mail账户 配置链接前面从extman拷贝的 mysql_virtual* 文件 virtual_mailbox_domains = proxy:mysql:/etc/postfix/sql/mysql_virtual_domains_maps.cf proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps virtual_alias_maps = mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf virtual_mailbox_domains = mysql:/etc/postfix/sql/mysql_virtual_domains_maps.cf virtual_mailbox_maps = mysql:/etc/postfix/sql/mysql_virtual_mailbox_maps.cf virtual_transport = maildrop: virtual_uid_maps = static:5000 virtual_gid_maps = static:5000 virtual_transport = dovecot dovecot_destination_recipient_limit = 1
2.2配置 master.cf
添加以下两行;flaage 前需要有空格 # vi /etc/postfix/master.cf dovecot unix - n n - - pipe flags=DRhu user=18mail:18mail argv=/usr/libexec/dovecot/dovecot-lda -f ${sender} -d ${recipient}
3、配置 dovecot
3.1 dovecot.conf 文件
[root@18mail dovecot]# vi dovecot.conf
protocols = imap pop3 listen = * # 日志目录 文件需要设置为 dovecot 权限; info_log_path = /var/log/dovecot-info.log debug_log_path = /var/log/dovecot-debug.log dict { #quota = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext #expire = sqlite:/etc/dovecot/dovecot-dict-sql.conf.ext } !include conf.d/*.conf !include_try /etc/dovecot/local.conf # dovecot-sql.conf.ext 下面自己创建编辑 passdb { driver = sql args = /etc/dovecot/dovecot-sql.conf.ext # 这个可以在当前目录手动创建 } # 18mail 为前面创建的邮箱专用账户 userdb { driver = static args = uid=5000 gid=5000 home=/home/18mail/%d/%n } ####调试日志 auth_debug_passwords=yes mail_debug=yes auth_verbose=yes auth_verbose_passwords=plain
3.2 手动创建 dovecot-sql.conf.ext 认证文件
需要设置 extmail 账户密码 # vi dovecot-sql.conf.ext
driver = mysql connect = host=localhost dbname=extmail user=extmail password=extmail default_pass_scheme = MD5-CRYPT password_query = SELECT username AS user,password FROM mailbox WHERE username = ‘%u‘ AND active=‘1‘ user_query = SELECT maildir, 5000 AS uid, 5000 AS gid, CONCAT(‘dict:storage=‘,floor(quota/1000),‘ proxy::quota‘) as quota FROM mailbox WHERE username = ‘%u‘ AND active=‘1‘
4、配置之后 进行重启
# service postfix restart
# chkconfig postfix on
# service dovecot restart
# chkconfig dovecot on
七、配置 httpd
1、unix-syslog 安装
配置httpd后启动时会有unix-syslog 报错;需要安装 UNIX-syslog 模块;
# wget http://www.cpan.org/authors/id/M/MH/MHARNISCH/Unix-Syslog-1.1.tar.gz 解压缩进行编译安装
# cd Unix-Syslog # perl Makefile.PL # make && make install
2、配置 extmail 虚拟主机;
2.1 配置httpd.conf
最后添加两行指定一个extmail虚拟主机;
# vi /etc/httpd/conf/httpd.conf
# 指定extmail虚拟主机
NameVirtualHost *:80 Include conf/vhost_extmail.conf
2.2 配置虚拟 vhost_extmail.conf 主机:
# vi /var/www/conf/vhost_extmail.conf
<VirtualHost *:80> ServerName mail.18mail.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/ SuexecUserGroup 18mail 18mail </VirtualHost>
3、启动 web
# /etc/init.d/httpd restart
# chkconfig httpd on
八、防火墙配置
1、配置 iptables 开放相关端口 25 110 143 80 3306 (由于没有SSL 验证 )
# vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 18 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 53 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 110 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 143 -j ACCEPT
重新启动:
# /ect/init.d/iptables restart
九、收发测试
http://mail.18mail.com
extman 默认的登录账户密码root@extmail.org 和 extmail*123*;
前面在 init.sql 更改为自己的18mail;;我可以用自己的进行登陆;
1、web 管理端测试:
2、web 客户端测试:
3、 Foxmail 收发测试
标签:perm 登陆 ado MF 5.5 base 编辑 tcl 3.2
原文地址:https://www.cnblogs.com/sharesdk/p/9215606.html