postfix+mysql+dovecot+extmail 邮件系统

安装mysql

yum install mysql-server -y
/etc/init.d/mysqld start
/usr/bin/mysql_secure_installation 安全配置
mysql -uroot -p123    登录方式
mysqladmin -u root -h desktop44.example.com password 'new-password' 远程登录mysql
mysqladmin -uroot -p123 password westos 修改密码

如果你忘记了mysql密码,你可以这么做
/etc/init.d/mysqld stop
mysqld_safe --skip-grant-tables & 跳过权限表
mysql    现在进入的模式相当于系统的单用户
update user set password='' where user='root'; 清空root密码
/etc/init.d/mysqld restart 重启服务 刚刚后台运行了 mysqld_safe
mysqladmin -uroot password 123

使用web访问msql
cd phpmyadmin
cp config.sample.inc.php config.inc.php
vi config.inc.php
$cfg['blowfish_secret'] = 'aaa'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

默认' ' 中间为空,随便添加些字符就可以 
yum install php php-mysql -y   发布的网页是php页面
/etc/init.d/httpd restart
192.168.0.44/phpadmin
选择 中文utf8登录

mkdir /var/www/extsuite
tar zxf ~/extman-1.1.tar.gz -C .
tar zxf ~/extmail-1.2.tar.gz -C .
cd /var/www/extsuite/extman/docs
mysql -uroot -p123 < extmail.sql

修改登录密码
mysql -uroot -p123 < init.sql   修改init.sql  修改postmaster和root的登录密码

cp mysql_virtual_alias_maps.cf /etc/postfix/mysql-alias.cf
cp mysql_virtual_domains_maps.cf /etc/postfix/mysql-domains.cf
cp mysql_virtual_mailbox_maps.cf /etc/postfix/mysql-mailboxs.cf  拷贝模板到指定目录

INSTALL里面是默认httpd的配置,将虚拟主机添加到/etc/httpd/conf/httpd.conf(extmail和extman里面都有INSTALL,添加到一个虚拟主机里面就行)

vi /etc/httpd/conf/httpd.conf

DocumentRoot /var/www/html
ServerName desktop144.example.com


ServerName mail.extmail.org
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 vmail vmail

cd /var/ww/extsuite/extmail
chown -R vmail.vmail cgi
yum install perl-CGI -y

cp web.mail.cf.default   webmail.cf
vi webmail.cf
SYS_LOG_ON = 0
SYS_MAILDIR_BASE = /home/vmail/
SYS_CRYPT_TYPE = plain
SYS_MYSQL_USER = extmail
SYS_MYSQL_PASS = extmail
SYS_MYSQL_DB = extmail
SYS_MYSQL_HOST = localhost

修改extmail里面的wenmail.cf SYS_LOG_ON = 1    如果不安装下面的文件,打开网页时就会提示缺少Unix-Syslog
tar zxf Unix-Syslog-1.1.tar.gz
cd Unix-Syslog
vi README
perl Makefile.PL
yum install perl-ExtUtils-MakeMaker -y
perl Makefile.PL
make test
yum install gcc -y
make install

cd extman                 和extmial同样
chown -R vmail.vmail cgi
cp webman.cf.default webman.cf
yum install perl-GD -y        验证码图片支持
vi webman.cf
SYS_MAILDIR_BASE = /home/vmail
SYS_SESS_DIR = /tmp/
SYS_CAPTCHA_ON = 1            验证码
SYS_CAPTCHA_LEN = 4
SYS_CRYPT_TYPE = plain        明文密码

postfix配置

useradd -u 600 -s /sbin/nologin vmail  建立一个邮件存放目录

postconf  -m 可以查看postfix支持

postconf -d 查看默认设置  -n查看当前设置监听所有的25端口

postconf -e virtual_mailbox_base=/home/vmail 设置存放位置

postconf -e virtual_uid_maps=static:600 以UID为600的用户身份执行

postconf -e virtual_gid_maps=static:600 以GID为600的用户身份执行

postconf -e virtual_alias_maps=mysql:/etc/postfix/mysql-alias.cf

postconf -e virtual_mailbox_domains=mysql:/etc/postfix/mysql-domains.cf

postconf -e virtual_mailbox_maps=mysql:/etc/postfix/mysql-mailboxs.cf

postmap -q "[email protected]" mysql:/etc/postfix/mysql-alias.cf

postmap -q "extmail.org" mysql:/etc/postfix/mysql-domains.cf

postmap -q "[email protected]" mysql:/etc/postfix/mysql-mailboxs.cf

mail [email protected]    发送一封测试邮件

dovecot配置

vi /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:/home/vmail/%d/%n/Maildir
first_valid_uid = 600
vi /etc/dovecot/conf.d/10-auth.conf
!include auth-sql.conf.ext
cp dovecot-sql.conf.ext /etc/dovecot/
vi dovecot-sql.conf.ext
driver = mysql 默认不支持mysql 需要安装 yum install dovecot-mysql.x86_64 -y
connect = host=localhost dbname=extmail user=extmail password=extmail
default_pass_scheme = PLAIN
password_query = \
SELECT username, domain, password \
FROM mailbox WHERE username = '%u' AND domain = '%d'
user_query = SELECT maildir, 600 AS uid, 600 AS gid FROM extmail WHERE username = '%u'

ok,完成了,域名访问需要主机记录或者是BIND,访问前台

http://mail.extmail.org

后台 http://mail.extmail.org/extman