使用postfix,cyrus-sasl,courier-authlib,mysql,dovecot,extmail,extman搭建电子邮件系统,可以使用web方式以虚拟账号注册登录邮箱,并且发送接受邮件,实现电子邮件功能。

配置详细步骤如下

搭建dns服务
dns指向
[root@localhost ~]# vim /etc/resolv.conf
nameserver192.168.20.20
[root@mail ~]# mkdir /mnt/cdrom
[root@mail ~]# mount /dev/cdrom /mnt/cdrom
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@mail ~]# cd /mnt/cdrom/Server/
[root@mail Server]# yum install bind
[root@mail Server]# yum install bind-chroot
[root@mail Server]# yum install caching*
[root@mail Server]# cd /var/named/chroot/etc/
[root@mail etc]# cp -p named.caching-nameserver.conf named.conf
[root@mail etc]# vim named.conf
listen-on port 53 { any; };
allow-query{ any; };
allow-query-cache { any; };
match-clients{ any; };
match-destinations { any; };
[root@mail etc]# cd /var/named/chroot/var/named/
[root@mail named]# cp -p localhost.zone a.org.zone
[root@mail named]# vim a.org.zone
$TTL86400
@IN SOA ns.a.org.       root (
42              ; serial (d. adams)
3H              ; refresh
15M             ; retry
1W              ; expiry
1D )            ; minimum
IN NS           ns.a.org.
nsIN A            192.168.20.20
mailIN A            192.168.20.20
POP3IN CNAME        mail
smtpIN CNAME        mail
@IN MX 10        mail
[root@mail named]# service named start
启动 named:[确定]
[root@mail named]# rndc reload
server reload successful
[root@mail named]# chkconfig named on
关闭sendmail
[root@mail named]# service sendmail stop
关闭 sm-client:[确定]
关闭 sendmail:[确定]
[root@mail named]# chkconfig sendmail off
安装所需的rpm包
[root@mail named]# yum install httpd php php-mysql mysql mysql-server mysql-devel openssl-devel dovecot perl-DBD-MySQL tcl tcl-devel libart_lgpl libart_lgpl-devel libtool-ltdl libtool-ltdl-devel expect
启动mysql数据库,并给用户设置密码
[root@mail named]# service mysqld start
启动 MySQL:[确定]
[root@mail named]# chkconfig mysqld on
[root@mail named]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> SET PASSWORD FOR root@'localhost'=PASSWORD('redhat');
Query OK, 0 rows affected (0.00 sec)
mysql> SET PASSWORD FOR root@'127.0.0.1'=PASSWORD('redhat');
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY 'redhat';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
一:安装postfix
[root@mail ~]# tar -zxvf postfix-2.8.2.tar.gz -C /usr/local/src
[root@mail ~]# cd /usr/local/src/
[root@mail src]# cd postfix-2.8.2/
[root@mail postfix-2.8.2]# groupadd -g 2525 postfix
[root@mail postfix-2.8.2]# useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
[root@mail postfix-2.8.2]# groupadd -g 2526 postdrop
[root@mail postfix-2.8.2]# useradd -g postdrop -u 2526 -s /bin/false -M postdrop
[root@mail postfix-2.8.2]# make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS ' 'AUXLIBS=-L/usr/lib/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2-lssl -lcrypto'
[root@mail postfix-2.8.2] make
[root@mail postfix-2.8.2] make install
生成别名二进制文件
[root@mail postfix-2.8.2]# newaliases
[root@mail postfix-2.8.2]# postfix start
postfix/postfix-script: starting the Postfix mail system
[root@mail postfix-2.8.2]# postconf -m
btree
cidr
environ
hash
internal
mysql//postfix支持mysql
[root@mail postfix-2.8.2]# postconf -a
cyrus
dovecot
[root@mail postfix-2.8.2]# mkdir /tmp/abc
[root@mail postfix-2.8.2]# cd /tmp/abc/
[root@mail abc]# cp /mnt/cdrom/Server/postfix-2.3.3-2.1.el5_2.i386.rpm./
[root@mail abc]# rpm2cpio postfix-2.3.3-2.1.el5_2.i386.rpm |cpio -id
[root@mail ~]# cd /tmp/abc/etc/rc.d/init.d/
[root@mail init.d]# cp postfix /etc/init.d/
[root@mail init.d]# service postfix start
启动 postfix:[确定]
[root@mail init.d]# chkconfig --add postfix
[root@mail init.d]# chkconfig --list |grep postfix
postfix0:关闭1:关闭2:启用3:启用4:启用5:启用6:关闭
编辑postfix文档
[root@mail init.d]# vim /etc/postfix/main.cf
myhostname = mail.a.org
mydomain = a.org
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks =  127.0.0.0/8
[root@mail init.d]# service postfix restart
关闭 postfix:[确定]
启动 postfix:[确定]
二:为postfix开启基于cyrus-sasl的认证功能
[root@mail init.d]# vim /etc/postfix/main.cf
############################CYRUS-SASL############################
655 broken_sasl_auth_clients = yes
656 smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_hostname,reject_unknown_sender_domain,reject_non_fqdn_sende    r,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,r    eject_unauth_destination
657 smtpd_sasl_auth_enable = yes
658 smtpd_sasl_local_domain = $myhostname
659 smtpd_sasl_security_options = noanonymous
[root@mail init.d]# cd /usr/lib/sasl2/
[root@mail init.d]# cd /usr/lib/sasl2/
[root@mail sasl2]# cp -p Sendmail.conf smtpd.conf
[root@mail sasl2]# vim smtpd.conf
pwcheck_method:saslauthd
mech_list: LOGIN PLAIN
[root@mail sasl2]# service saslauthd start
启动 saslauthd:[确定]
[root@mail sasl2]# chkconfig saslauthd on
[root@mail sasl2]# telnet 127.0.0.1 25
ehlo 127.0.0.1
250-mail.a.org
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
三:安装Courier authentication library
[root@mail ~]# tar -jxvf courier-authlib-0.63.1.20111230.tar.bz2 -C /usr/local/src/
[root@mail courier-authlib-0.63.1.20111230]# ./configure --prefix=/usr/local/courier-authlib --sysconfdir=/etc --with-authmysql --with-mysql-libs=/usr/lib/mysql --with-mysql-includes=/usr/include/mysql --with-redhat --with-authmysqlrc=/etc/authmysqlrc --with-authdaemonrc=/etc/authdaemonrc --with-ltdl-lib=/usr/lib --with-ltdl-include=/usr/include
[root@mail courier-authlib-0.63.1.20111230]# make
[root@mail courier-authlib-0.63.1.20111230]# make install
[root@mail courier-authlib-0.63.1.20111230]# chmod 755 /usr/local/courier-authlib/var/spool/authdaemon
[root@mail courier-authlib-0.63.1.20111230]# cp /etc/authdaemonrc.dist /etc/authdaemonrc
[root@mail courier-authlib-0.63.1.20111230]# cp /etc/authmysqlrc.dist /etc/authmysqlrc
[root@mail courier-authlib-0.63.1.20111230]# vim /etc/authdaemonrc
authmodulelist="authmysql"
authmodulelistorig="authmysql"
[root@mail courier-authlib-0.63.1.20111230]# vim /etc/authmysqlrc
MYSQL_SERVER localhost
MYSQL_PORT 3306mysql监听的端口
MYSQL_USERNAME extmail数据库的所有者的用户名
MYSQL_PASSWORD extmail密码
MYSQL_SOCKET /var/lib/mysql/mysql.sock
MYSQL_DATABASE extmail
MYSQL_USER_TABLE mailbox
MYSQL_CRYPT_PWFIELD password
MYSQL_UID_FIELD '2525'
MYSQL_GID_FIELD '2525'
MYSQL_LOGIN_FIELD username
MYSQL_HOME_FIELD concat('/var/mailbox/',homedir)
MYSQL_NAME_FIELD name
MYSQL_MAILDIR_FIELD concat('/var/mailbox/',maildir)
[root@mail ~]# cd /usr/local/src/courier-authlib-0.63.1.20111230/
[root@mail courier-authlib-0.63.1.20111230]# cp courier-authlib.sysvinit /etc/init.d/courier-authlib
[root@mail courier-authlib-0.63.1.20111230]# chmod 755 /etc/init.d/courier-authlib
[root@mail courier-authlib-0.63.1.20111230]# service courier-authlib start
Starting Courier authentication services: authdaemond
[root@mail courier-authlib-0.63.1.20111230]# chkconfig --add courier-authlib
[root@mail courier-authlib-0.63.1.20111230]# chkconfig courier-authlib on
[root@mail courier-authlib-0.63.1.20111230]# echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf.d/courier-authlib.conf
[root@mail courier-authlib-0.63.1.20111230]# ldconfig -v
[root@mail courier-authlib-0.63.1.20111230]# ldconfig -pv |grep cour
新建虚拟用户邮箱所在的目录,并将其权限赋予postfix用户:
[root@mail courier-authlib-0.63.1.20111230]# mkdir -pv /var/mailbox
[root@mail courier-authlib-0.63.1.20111230]# chown -R postfix /var/mailbox
修改验证方式
[root@mail courier-authlib-0.63.1.20111230]# vim /usr/lib/sasl2/smtpd.conf
pwcheck_method:saslauthd
mech_list: LOGIN PLAIN
pwcheck_method: authdaemond
log_level: 3
mech_list:PLAIN LOGIN
authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket
~
[root@mail courier-authlib-0.63.1.20111230]# service saslauthd restart
停止 saslauthd:[确定]
启动 saslauthd:[确定]
[root@mail courier-authlib-0.63.1.20111230]# service courier-authlib restart
Stopping Courier authentication services: authdaemond
Starting Courier authentication services: authdaemond

四:使postfix支持虚拟域和虚拟用户

[root@mail courier-authlib-0.63.1.20111230]# vim /etc/postfix/main.cf
663 ########################Virtual Mailbox Settings########################
664 virtual_mailbox_base = /var/mailbox
665 virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
666 virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
667 virtual_alias_domains =
668 virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
669 virtual_uid_maps = static:2525
670 virtual_gid_maps = static:2525
671 virtual_transport = virtual
672 maildrop_destination_recipient_limit = 1
673 maildrop_destination_concurrency_limit = 1
674 ##########################QUOTA Settings########################
675 message_size_limit = 14336000
676 virtual_mailbox_limit = 20971520
677 virtual_create_maildirsize = yes
678 virtual_mailbox_extended = yes
679 virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
680 virtual_mailbox_limit_override = yes
681 virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspacequota, please Tidy your mailbox and try again later.
682 virtual_overquota_bounce = yes
使用extman源码目录下docs目录中的extmail.sql和init.sql建立数据库
[root@mail ~]# tar -zxvf extman-1.1.tar.gz
[root@mail ~]# cd extman-1.1
[root@mail extman-1.1]# cd docs/
[root@mail docs]# mysql -u root -p <extmail.sql
Enter password:
[root@mail docs]# mysql -u root -p <init.sql
Enter password:
[root@mail docs]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+--------------------+
| Database|
+--------------------+
| information_schema |
| extmail|
| mysql|
| test|
+--------------------+
4 rows in set (0.00 sec)
mysql> use extmail
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+-------------------+
| Tables_in_extmail |
+-------------------+
| alias|
| domain|
| domain_manager|
| mailbox|
| manager|
+-------------------+
5 rows in set (0.00 sec)
mysql>
[root@mail docs]# cp mysql* /etc/postfix/
授予用户extmail访问extmail数据库的权限
[root@mail docs]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> GRANT all privileges on extmail.* TO extmail@localhost IDENTIFIED BY 'extmail';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT all privileges on extmail.* TO extmail@127.0.0.1 IDENTIFIED BY 'extmail';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> \q
Bye
[root@mail docs]# service postfix restart
关闭 postfix:[确定]
启动 postfix:[确定]
五:配置dovecot
[root@mail docs]# vim /etc/dovecot.conf
mail_location = maildir:/var/mailbox/%d/%n/Maildir
auth default {
mechanisms = plain
passdb sql {
args = /etc/dovecot-mysql.conf
}
userdb sql {
args = /etc/dovecot-mysql.conf
}
[root@mail docs]# vim /etc/dovecot-mysql.conf
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'
[root@mail docs]# vim /etc/postfix/main.cf
home_mailbox = Maildir/
[root@mail docs]# service dovecot restart
停止 Dovecot Imap:[失败]
启动 Dovecot Imap:[确定]
[root@mail docs]# chkconfig dovecot on
[root@mail docs]# service postfix restart
关闭 postfix:[确定]
启动 postfix:[确定]
六:安装Extmail-1.2
[root@mail ~]# tar zxvf extmail-1.2.tar.gz
[root@mail ~]# mkdir -pv /var/www/extsuite
mkdir: 已创建目录 “/var/www/extsuite”
[root@mail ~]# mv extmail-1.2 /var/www/extsuite/extmail
[root@mail ~]# mv extman-1.1 /var/www/extsuite/extman
[root@mail extmail]# cp webmail.cf.default webmail.cf
[root@mail extmail]# vim webmail.cf
SYS_USER_LANG = zh_CN
SYS_MYSQL_USER = extmail
SYS_MYSQL_PASS = extmail
SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket
[root@mail extmail]# service httpd start
启动 httpd:httpd: apr_sockaddr_info_get() failed for mail.a.org
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[确定]
[root@mail extmail]# chkconfig httpd on
[root@mail extmail]# vim /etc/httpd/conf/httpd.conf
User postfix
Group postfix
<VirtualHost *:80>
ServerName mail.test.com
DocumentRoot /var/www/extsuite/extmail/html/
ScriptAlias /extmail/cgi /var/www/extsuite/extmail/cgi
Alias /extmail /var/www/extsuite/extmail/html
</VirtualHost>
修改 cgi执行文件属主为apache运行身份用户
[root@mail extmail]# chown -R postfix.postfix /var/www/extsuite/extmail/cgi/
[root@mail extmail]# service httpd restart
停止 httpd:[确定]
启动 httpd:httpd: apr_sockaddr_info_get() failed for mail.a.org
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[确定]
七:安装extman
[root@mail ~]# tar -zxvf extman-1.1.tar.gz
[root@mail ~]# mv extman-1.1 /var/www/extsuite/extman
[root@mail extman]# cp webman.cf.default webman.cf
[root@mail extman]# vim webman.cf
12 SYS_MAILDIR_BASE = /var/mailbox
21 SYS_CAPTCHA_ON = 0
[root@mail extman]# chown -R postfix.postfix /var/www/extsuite/extman/cgi/
[root@mail extman]# vim /etc/httpd/conf/httpd.conf
999 ScriptAlias /extman/cgi /var/www/extsuite/extman/cgi
1000 Alias /extman /var/www/extsuite/extman/html
[root@mail extman]# mkdir -pv /tmp/extman
mkdir: 已创建目录 “/tmp/extman”
[root@mail extman]# chown postfix.postfix /tmp/extman
八:依赖关系解决
[root@mail ~]# tar -zxvf Unix-Syslog-1.1.tar.gz
[root@mail ~]# cd Unix-Syslog-1.1
[root@mail Unix-Syslog-1.1]# perl Makefile.PL
[root@mail Unix-Syslog-1.1]# make
[root@mail Unix-Syslog-1.1]# make install
[root@mail Unix-Syslog-1.1]# service httpd restart
停止 httpd:[确定]
启动 httpd:httpd: apr_sockaddr_info_get() failed for mail.a.org
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[确定]
测试:
使用默认帐号登录

添加域

查看域列表

注册邮箱

登录邮箱

写邮件

接收邮件

查看日志
[root@mail ~]# tail -f /var/log/maillog
Sep 11 23:18:57 localhost postfix/qmgr[20119]: 3787696647: from=<nxl@a.org>, size=539, nrcpt=1 (queue active)
Sep 11 23:18:57 localhost postfix/virtual[20523]: 3787696647: to=<nxl01@c.org>, relay=virtual, delay=0.17, delays=0.1/0.01/0/0.06, dsn=2.0.0, status=sent (delivered to maildir)
Sep 11 23:18:57 localhost postfix/qmgr[20119]: 3787696647: removed
Sep 11 23:19:41 localhost extmail[20530]: user=<nxl01@c.org>, client=192.168.20.1, module=login, status=loginok

转载于:https://blog.51cto.com/niuxiaolin/988492

搭建基于虚拟账号的电子邮件系统相关推荐

  1. 基于虚拟用户的电子邮件系统

    在现实生活中,我们根本不可能为邮件用户在邮件服务器上添加系统账号.互联网上成千上万的人每天都在进行邮件传输和邮箱申请. 正是采用了利用虚拟账号映射成我们邮件系统的系统账号.现实生活中的126 .QQ. ...

  2. 基于虚拟账号的邮件系统

    按照如下图所以创建基于虚拟账号的邮件系统: 如上图所示:客户端登录邮件系统需要经过cyrus-sasl函数库账号的认证,但是cyrus-sasl无法调用mysql,所以必须安装courier-auth ...

  3. Pure-Ftp:基于虚拟账号的FTP服务器

    小编:为了实现局域网用户的文件共享服务,FTP服务器在企业网中扮演着很重要的角色.在Linux环境下,传统的基于vsftpd搭建的FTP服务器,存在着很多不足之处,不能支持虚拟账号的概念,管理起来很不 ...

  4. 基于虚拟帐号的邮件系统extmail(1)

    基于虚拟帐号的邮件系统extmail 如果你经常使用邮箱的话, 你发现像网易.163等邮箱都是通过使用网页直接申请并且使用的,它提供给用户一种更快捷方便的操作,但我们前面所讲的sendmail与pos ...

  5. PXE安装Centos65 postfix+exmail+mysql实现基于 虚拟用户的web邮件系统

    PXE安装Centos postfix+exmail+mysql实现基于 虚拟用户的web邮件系统 在实现centos+postfix的web内网邮件之前,参考了许多网上.书本知识,经过两次大的改动, ...

  6. 计算机网络局域网仿真搭建,基于虚拟仿真技术的计算机网络实验室的构建.pdf...

    基于虚拟仿真技术的计算机网络实验室的构建.pdf 第29卷第1期 湖北汽车工业学院学报 Vol.29 No.1 2015 年3月 JournalofHubeiUniversityofAutomotiv ...

  7. 基于虚拟账号的邮件系统之×××

    postfix是Wietse Venema在IBM的GPL协议之下开发的MTA(邮件传输代理)软件.postfix是Wietse Venema想要为使用最广泛的sendmail提供替代品的一个尝试.在 ...

  8. 基于虚拟帐号的邮件系统(extmail)上

    构想图: 所需主要源码包: postfix-2.8.2.tar.gz courier-authlib-0.63.0.tar.bz2 extmail-1.2.tar.gz, extman-1.1.tar ...

  9. 基于虚拟帐号的邮件系统

    1.修改主机名 # vim /etc/sysconfig/network NETWORKING=yes NETWORKING_IPV6=no HOSTNAME=mail.sina.com # vim ...

最新文章

  1. 元数据驱动的微服务架构(上)
  2. [Qt教程] 第23篇 数据库(三)利用QSqlQuery类执行SQL语句
  3. CF1054D-Changing Array【贪心】
  4. Java设计模式、框架、架构、平台之间的关系
  5. 第七届蓝桥杯省赛大学B组C/C++---剪邮票---DFS
  6. JDK下载与安装教程
  7. linux ls-la/boot,CentOS系统启动/boot/vmlinuz修复(实验)
  8. 资源分享 | 网易云课堂价值 399 的 office 三合一自学教程
  9. Z国的货币系统包含面值1元、4元、16元、64元共计4种硬币,以及面值1024元的纸币。现在小Y使用1024元的纸币购买了一件价值为N的商品,请问最少他会收到多少硬币?
  10. Edge浏览器保存主页视频的方法
  11. 社交软件红包技术解密(十):手Q客户端针对2020年春节红包的技术实践
  12. 吴恩达机器学习(十一)—— 应用机器学习的建议
  13. 磁盘柜支持linux,linux 连接磁盘柜
  14. 使用HTML表格制作简易的个人简历表
  15. win10增加matlab虚拟内存,详细教你win10如何增加虚拟内存
  16. 英国工程专业最佳大学TOP10成绩要求多高?
  17. Frontline ComProbe Protocol Analysis System(CPAS)简单使用说明
  18. 深聊全链路压测之:第二十一讲 | 如何搭建GoReplay压测平台。
  19. Scipy sparse中关于CSC矩阵的自我理解
  20. Java编程基础(3)——字典类型

热门文章

  1. 《C和指针》读书笔记
  2. 细数开源历史上的九个重大事件
  3. Github Pages 搭建个人网站
  4. 升降压斩波电路matlab,升降压直流斩波电路及matlab仿真.doc
  5. 联想服务器开启虚拟化,联想电脑虚拟化开启方法
  6. c语言编2048,c语言编写的2048游戏代码,大家可以参考一下这些
  7. BeanFactory和ApplicationContext有什么区别
  8. mac安装dubbo-admin
  9. 线程可见性和关键字volatile
  10. linux安装mysql不成功怎么处理_Linux上安装MySQL时出现不兼容的解决办法