extmail mysql数据库 重启_Extmail邮件服务器部署

前言 extmail是一款开源的webmail系统。 现有的基于extmail的部署架构有如下两种模式: 第一种:postfix + extmail + devocot + courier-authdaemon 第二种:postfix + extmail + courier-authdaemon + courier-imap + courier-pop3 + maildrop 本次部署基于第二种模式进行配置

部署

部署环境

OS:ubuntu 11.04 server

Extmail:1.2

Extman:1.1

依赖包安装

apt-get install mysql-client-5.1 mysql-server apache2 postfix postfix-mysql postfix-doc courier-authdaemon courier-authlib-mysql courier-pop courier-pop-ssl courier-imap courier-imap-ssl libsasl2-modules libsasl2-modules-sql sasl2-bin libpam-mysql openssl libapache2-mod-fastcgi libfcgi-perl build-essential libtool libnet-server-perl libnet-cidr-perl libberkeleydb-perl arc zoo lzop liblzo2-dev libstdc++5 libgd-gd2-perl libfile-tail-perl libdigest-sha1-perl libdigest-HMAC-perl libnet-ip-perl libnet-dns-perl libhtml-tagset-perl libhtml-parser-perl libio-stringy-perl libio-multiplex-perl libio-socket-ssl-perl libio-zlib-perl libnet-ssleay-perl libunix-syslog-perl libtimedate-perl libmailtools-perl libconvert-binhex-perl libconvert-tnef-perl libconvert-uulib-perl libcompress-zlib-perl libarchive-zip-perl libarchive-tar-perl perl-suid

下载extmail和extman google一下即可找到官方下载地址,下载最新版本,可能看到文档的时候我这个版本已经不是最新,直接下最新的即可。 下载完毕之后将文档解压到/var/www/extsuite/extmail和/var/www/extsuite/extman 将postfix需要使用的虚拟主机的配置文件拷贝到postfix的etc文件夹下面

cp /var/www/extsuite/extman/docs/mysql_virtual_*.cf /etc/postfix/

用户分配

特别说明:因为extmail系统里面使用的用户的uid和gid都是1000,如果你使用的ubuntu系统初始化一个admin用户,这个用户的 uid和gid就是1000,但是你又不想用此用户作为extmail的运行用户,那就必须新建一个用户,然后将此用户的uid和gid与初始化用户替 换。

useradd -m -d /home/www -s /bin/bash www passwd www 以上新建用户的uid和pid都是1001,可以修改passwd文件和group文件进行替换。

文件属性修改 chmod 755 /etc/postfix/mysql_virtual_*.cf chgrp postfix /etc/postfix/mysql_virtual_*.cf chown -R www:www /var/www/extsuite/extmail/cgi/ chown -R www:www /var/www/extsuite/extman/cgi/ cd /var/www/extsuite/extmail/ cp webmail.cf.default webmail.cf cd /var/www/extsuite/extman/ cp webman.cf.default webman.cf

修改extmail配置文件 vim /var/www/extsuite/extmail/webmail.cf

SYS_USER_LANG = zh_CN  # 语言设置 SYS_MYSQL_USER = extmail # 默认访问数据库的用户名 SYS_MYSQL_PASS = extmail # 默认访问数据库的密码 SYS_MYSQL_DB = extmail  # 默认访问数据库的名字 SYS_MYSQL_SOCKET = /var/run/mysqld/mysqld.sock SYS_AUTHLIB_SOCKET = /var/run/courier/authdaemon/socket SYS_MAILDIR_BASE = /home/vmail SYS_MESSAGE_SIZE_LIMIT = 102400000 vim /var/www/extsuite/extman/webman.cf

SYS_CAPTCHA_ON = 0 ##用于关闭后台登录时的验证码 SYS_MAILDIR_BASE = /home/vmail SYS_MYSQL_SOCKET = /var/run/mysqld/mysqld.sock SYS_LANG = zh_CN SYS_GROUPMAIL_SENDER = admin@1k8k.com vim /var/www/extsuite/extman/contrib/passwd2ext.pl

my $sock = '/var/run/mysqld/mysqld.sock';

Extmail 数据库初始化 直接导入sql脚本

mysql -u root -pgaojinbo.com < /var/www/extsuite/extman/docs/extmail.sql mysql -u root -pgaojinbo.com < /var/www/extsuite/extman/docs/init.sql 临时文件夹建立

mkdir /tmp/extman chown -R www:www /tmp/extman 初始化postmaster@extmail.org帐户的Maildir文件夹

cd /var/www/extsuite/extman/tools ./maildirmake.pl /home/vmail/extmail.org/postmaster/Maildir chown -R www:www /home/vmail/extmail.org/

postfix配置

# See /usr/share/postfix/main.cf.dist for a commented, more complete version # Debian specific:  Specifying a file name will cause the first # line of that file to be used as the name.  The Debian default # is /etc/mailname. #myorigin = /etc/mailname smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) biff = no # appending .domain is the MUA's job. append_dot_mydomain = no # Uncomment the next line to generate "delayed mail" warnings #delay_warning_time = 4h readme_directory = /usr/share/doc/postfix # TLS parameters smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key smtpd_use_tls=no smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for # information on enabling SSL in the smtp client. mydomain = 1k8k.com myhostname = mail.1k8k.com alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = 127.0.0.1,mail.1k8k.com relayhost = mynetworks = 127.0.0.1 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = loopback-only html_directory = /usr/share/doc/postfix/html ######### virtual config############ virtual_alias_domains = virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_limit_maps.cf virtual_mailbox_base = /home/vmail virtual_uid_maps = static:1000 virtual_gid_maps = static:1000 virtual_create_maildirsize = yes virtual_mailbox_extended = yes virtual_overquota_bounce = yes virtual_mailbox_limit_override = yes virtual_maildir_limit_message = Sorry, the your Maildir has overdrawn your diskspace quota, please free up some of spaces of your ma ilbox try again. proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mai lbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $ transport_maps $mynetworks $virtual_mailbox_limit_maps ###########SMTP AUTH config############### broken_sasl_auth_clients = yes smtpd_sasl_auth_enable = yes #smtpd_sasl_local_domain = $myhostname smtpd_sasl_security_options = noanonymous ###########smtpd related config############ smtpd_client_restrictions = permit_sasl_authenticated smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination #smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unknown_sender_domain, reject_non_fqdn_hostname , reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_unauth_destination, reject_unauth_pipel ining, reject_invalid_hostname, check_recipient_maps ###### Maildrop config ######## maildrop_destination_recipient_limit = 1 virtual_transport = maildrop: 重启postfix,检查是否有语法错误

/etc/init.d/postfix restart

SMTP身份认证

cd /etc/postfix openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM -days 365 -x509

apache2配置 注意:apache2的配置不通的版本有很大的区别,这里配置可能需要根据你使用的版本调整,这个使用是2.2版本 vim /etc/apache2/sites-enabled/mail

ServerAdmin admin@1k8k.com ServerName mail.1k8k.com DocumentRoot /var/www/extsuite/extmail/html Alias /extmail/cgi/ /var/www/extsuite/extmail/dispatch.fcgi/ Alias /extmail /var/www/extsuite/extmail/html FastCgiExternalServer /var/www/extsuite/extmail/dispatch.fcgi -host 127.0.0.1:8888 -idle-timeout 240 SetHandler fastcgi-script ScriptAlias /extman/cgi/ /var/www/extsuite/extman/cgi/ Alias /extman /var/www/extsuite/extman/html ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined SuexecUserGroup vuser vgroup

SMTP认证设置 更改saslauthd vim /etc/default/saslauth 更改如下几项

START=yes    //设置开机自动启动 OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r" 创建文件/etc/pam.d/smtp 内容如下:

auth    required   pam_mysql.so user=extmail passwd=extmail host=127.0.0.1 db=extmail table=mailbox usercolumn=username passwdcolumn=password crypt=1 account sufficient pam_mysql.so user=extmail passwd=extmail host=127.0.0.1 db=extmail table=mailbox usercolumn=username passwdcolumn=password crypt=1 解释一下:其实就是定义一个查询的方式 crypt=1或者0表示加密或者不加密 注意对照你的数据库 还有用户名密码 请保持跟自己的一致 由于postfix处于chroot,要想调用到saslauthd 必须更改socket文件

mkdir -p /var/spool/postfix/var/run/saslauthd 创建smtpd.conf,并且内容如下:

pwcheck_method:saslauthd mech_list:plain login allow_plaintext: true auxprop_plugin: mysql sql_hostnames: 127.0.0.1 sql_user: extmail sql_password: extmail sql_database: extmail log_level:7 sql_select: SELECT password FROM mailbox WHERE username='%u@%r' and domain='%r' 修改的内容已经在前面添加进去,SMTP AUTH config和smtpd related config两个部分的配置文件

检测smtp(25)

telnet localhost 25 Trying 127.0.0.1… Connected to localhost. Escape character is ‘^]’. 220 mail.extmail.org ESMTP Postfix ehlo localhost  # 输入内容 250-mail.extmail.org 250-PIPELINING 250-SIZE 102400000 250-VRFY 250-ETRN 250-STARTTLS 250-AUTH PLAIN LOGIN 250-AUTH=PLAIN LOGIN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN auth login # 输入内容 334 VXNlcm5hbWU6 cG9zdG1hc3RlckBleHRtYWlsLm9yZw== # 输入内容 334 UGFzc3dvcmQ6 ZXh0bWFpbA== # 输入内容 235 2.7.0 Authentication successful # 显示认证成功 quit 221 2.0.0 Bye Connection closed by foreign host. 如果出现Authentication successful 表示成功咯

POP验证 vim /etc/courier/authdaemonrc

authmodulelist="authmysql" cp /etc/courier/authmysqlrc /etc/courier/authmysqlrc_orig cat /dev/null > /etc/courier/authmysqlrc vim /etc/courier/authmysqlrc

DEFAULT_DOMAIN          1k8k.com MYSQL_SERVER            127.0.0.1 MYSQL_USERNAME          extmail MYSQL_PASSWORD          extmail MYSQL_SOCKET            /var/run/mysqld/mysqld.sock MYSQL_PORT              3306 MYSQL_OPT               0 MYSQL_DATABASE          extmail MYSQL_USER_TABLE        mailbox MYSQL_CRYPT_PWFIELD     password MYSQL_UID_FIELD         104 MYSQL_GID_FIELD         112 MYSQL_LOGIN_FIELD       username MYSQL_HOME_FIELD        /home/vmail MYSQL_NAME_FIELD        name MYSQL_MAILDIR_FIELD     /home/vmail MYSQL_QUOTA_FIELD       quota MYSQL_SELECT_CLAUSE     SELECT username,password,domain,                uidnumber,gidnumber,                            CONCAT('/home/vmail/',homedir),          CONCAT('/home/vmail/',maildir),          quota,                                          name                                            FROM mailbox                                    WHERE username = '$(local_part)@$(domain)'      AND active = 1

配置Courier-POP3

vim /etc/courier/pop3d MAILDIRPATH=/home/vmail 配置Courier-IMAP

vi /etc/courier/imapd MAILDIRPATH=/home/vmail/ 重启服务

/etc/init.d/courier-authdaemon restart /etc/init.d/courier-imap restart /etc/init.d/courier-imap-ssl restart /etc/init.d/courier-pop restart /etc/init.d/courier-pop-ssl restart 测试Courier- Authlib是否能成功连接mysql

authtest -s login postmaster@extmail.org extmail 如果成功会显示如下:

Authentication succeeded. Authenticated: postmaster@extmail.org  (uid 1000, gid 1000) Home Directory: /home/vmail/extmail.org/postmaster Maildir: /home/vmail/extmail.org/postmaster/Maildir/ Quota: 104857600S Encrypted Password: $1$phz1mRrj$3ok6BjeaoJYWDBsEPZb5C0 Cleartext Password: extmail Options: disablesmtpd=0,disablesmtp=0,disablewebmail=0,disablenetdisk=0, disableimap=0,disablepop3=0,netdiskquota=52428800S

测试pop3 telnet localhost 110 Trying 127.0.0.1… Connected to localhost.localdomain (127.0.0.1). Escape character is ‘^]’. +OK Hello there. user postmaster@extmail.org  # 输入内容 +OK Password required. pass extmail # 输入内容 +OK logged in. list # 输入内容 +OK POP3 clients that break here, they violate STD53. . quit # 输入内容 +OK Bye-bye. Connection closed by foreign host. 图形日志配置 以下配置我未安装,所以正确与否并未论证 apt-get install mailgraph cp -r /var/www/extsuite/extman/addon/mailgraph_ext/ /usr/local/mailgraph_ext vi /usr/local/mailgraph_ext/mailgraph-init为:

MAIL_LOG=/var/log/mail.log cp /var/www/extsuite/extman/addon/mailgraph_ext/mailgraph-init /etc/init.d/mailgraph cp /var/www/extsuite/extman/addon/mailgraph_ext/qmonitor.pl /etc/init.d/qmonitor 启动服务

/etc/init.d/mailgraph start

安装Maildrop

apt-get install maildrop

vi /etc/maildropmysql.config //创建一个文件

hostname localhost port 3306 database extmail dbuser extmail dbpw extmail dbtable mailbox default_uidnumber 1000 default_gidnumber 1000 uidnumber_field uidnumber gidnumber_field gidnumber uid_field username homedirectory_field concat('/home/vmail/',homedir,'/') maildir_field concat('/home/vmail/',maildir) quota_field quota mailstatus_field active

修改/etc/maildroprc

vi /etc/maildroprc

logfile "/var/log/maildrop.log"

vi /var/log/maildrop.log

chown vuser:vgroup /var/log/maildrop.log chmod 766 /var/log/maildrop.log

vi /etc/logrotate.d/maildrop

/var/log/maildrop.log { daily notifempty missingok rotate 5 compress create 766 www www sharedscripts }

vi /etc/postfix/master.cf,注释掉原来maildrop的配置内容并改为:

maildrop   unix  -       n        n       -       -        pipe flags=DRhu  user=www argv=maildrop -w 90 -d ${user}@${nexthop} ${recipient} ${user}  ${extension} {nexthop} #flags前面必须空2格

由于maildrop不支持一次接收多个收件人,因此必须在/etc/postfix/main.cf增加参数,已经在前面main.cnf里面添加,就是Maildrop config里面的配置

创建vi /etc/quotawarnmsg,为邮箱空间超过配额时的警告邮件内容:

X-Comment: Rename/Copy this file to quotawarnmsg, and make appropriate changes X-Comment: See deliverquota man page for more information From: Mail Delivery System Reply-To: support@example.com To: Valued Customer:; Subject: Mail quota warning Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit Your mailbox on the server is now more than 90% full. So that you can continue to receive mail you need to remove some messages from your mailbox.

启动extman服务

/var/www/extsuite/extman/daemon/cmdserver -v -d

写入启机服务

echo "/var/www/extsuite/extman/daemon/cmdserver -v -d" >>/etc/rc.local

完成部署

登录http://mail.1k8k.com/extmail/ 前台,http://mail.1k8k.com/extman/后台

后台默认用户名 root@extmail.org 默认密码 extmail*123*,登录前台需要自己先添加一个用户

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值