Mail Server Postfix + Dovecot + Extmail + Extman Based on Virtual account

Source: Internet
Author: User
Tags dovecot

Mail Server (Postfix + Dovecot + Extmail + Extman Based on Virtual account)


Lab Topology


LAMP (Linux + Apache + MySQL + PHP) Environment Construction


First, we need to build a LAMP Environment


Install Apache


[Root @ mail apr-1.4.6] # tar-zxvf apr-util-1.5.1.tar.gz-C/usr/local/src/


[Root @ mail apr-1.4.6] # cd/usr/local/src/apr-1.4.6/


[Root @ mail apr-1.4.6] #./configure -- prefix =/usr/local/apr


[Root @ mail apr-1.4.6] # make


[Root @ mail apr-1.4.6] # make install


[Root @ mail src] # apr-util-1.5.1/cd/


[Root @ mail apr-util-1.5.1] #./configure -- with-apr =/usr/local/apr/bin/apr-1-config


[Root @ mail apr-util-1.5.1] # make


[Root @ mail apr-util-1.5.1] # make install


[Root @ mail cdrom] # cd/mnt/cdrom/Server/


[Root @ mail Server] # rpm-ivh/mnt/cdrom/Server/pcre-devel-6.6-2.el5_1.7.i386.rpm


Install http


[Root @ mail ~] # Tar-jxvf httpd-2.4.4.tar.bz2-C/usr/local/src/


[Root @ mail ~] # Cd/usr/local/src/httpd-2.4.4/


[Root @ mail httpd-2.4.4] #. /configure -- prefix =/usr/local/apache -- sysconfdir =/etc/httpd -- enable-so -- enable-ssl -- enable-rewrite -- with-apr =/usr/local/ apr/bin/apr-1-config -- with-apr-util =/usr/local/apr/bin/apu-1-config -- with-pcre-with-z -- enable-mpms-shared = all


[Root @ mail httpd-2.4.4] # make


[Root @ mail httpd-2.4.4] # make install


[Root @ mail ~] # Cd/etc/init. d/


[Root @ mail init. d] # chmod a + x httpd


[Root @ mail init. d] # ln-s/usr/local/apache/include // usr/include/apche


[Root @ mail init. d] # vim/etc/man. config


Install mysql


[Root @ mail ~] # Groupadd mysql


[Root @ mail ~] # Useradd-r-g mysql


[Root @ mail src] # cd/usr/local/


[Root @ mail local] # ln-s/usr/local/src/mysql-5.5.15-linux2.6-i686/mysql


[Root @ mail mysql] # chown-R mysql.


[Root @ mail mysql] # chgrp-R mysql.


[Root @ mail mysql] # scripts/mysql_install_db -- user = mysql


[Root @ mail mysql] # chown-R root.


[Root @ mail mysql] # chown-R mysql data


[Root @ mail mysql] # cp support-files/my-medium.cnf/etc/my. cnf


[Root @ mail mysql] # cp support-files/mysql. server/etc/init. d/mysqld


[Root @ mail mysql] # service mysqld start


Starting MySQL... [OK]


[Root @ mail mysql] # chkconfig -- add mysqld


Configure mysql Environment Variables


[Root @ mail mysql] # vim/etc/profile


[Root @ mail mysql] #./etc/profile


Create the mysql. conf file and add the library file path


[Root @ mail mysql] # vim/etc/ld. so. conf. d/mysql. conf



/Usr/local/mysql/lib


[Root @ mail mysql] # ldconfig


Process header files


[Root @ mail mysql] # ln-s include/usr/include/mysql


Add a password to the mysql database


Install php


[Root @ mail php-5.4.13] # tar-jxvf php-5.4.13.tar.bz2-C/usr/local/src/


[Root @ mail php-5.4.13] #. /configure -- prefix =/usr/local/php -- with-apxs2 =/usr/local/apache/bin/apxs -- with-mysql =/usr/local/mysql -- with-mysqli = /usr/local/mysql/bin/mysql_config -- enable-mbstring -- enable-xml -- with-png-dir -- with-png -- with-jpeg-dir -- with-zlib -- enable -mbstring -- with-freetype-dir



[Root @ mail php] # make


[Root @ mail php] # make install


Edit/etc/profile


Library File Processing


[Root @ mail php] # ldconfig


Process header files



[Root @ mail php] # ln-s/usr/local/php/include // usr/include/php


Support php module for editing apache configuration files



Set up exymail below


This is mainly used to build extmail in Beijing.


Disable the sendmail function of the Development Platform because you need to set up extmail.


Change host name and dns point



Disable sendmail and set it to disabled at startup




Upload the required software package to build extmail


Postfix-2.8.2.tar.gz


Courier-authlib-0.63.0.tar.bz2


Unix-Syslog-0.100.tar.gz


Extmail-1.2.tar.gz


Extman-1.1.tar.gz


Set saslauth service to start


Install other software packages


Yum install mysql-devel


Install postfix


[Root @ host ~] # Tar-zxvf postfix-2.8.2.tar.gz-C/usr/local/src/


[Root @ host ~] # Cd/usr/local/src/postfix-2.8.2/


[Root @ host postfix-2.8.2] # group-g 2525 postfix


-Bash: group: command not found


[Root @ host postfix-2.8.2] # groupadd-g 2525 postfix


[Root @ host postfix-2.8.2] # useradd-g postfix-u 2525-s/sbin/nologin-M postfix


[Root @ host postfix-2.8.2] # groupadd-g 2526 postdrop


[Root @ host postfix-2.8.2] # useradd-g postdrop-u 2526-s/bin/false-M postdro


The Mysql path must be correct.


[Root @ host postfix-2.8.2] # make & make install

Install_root: [/]/


Tempdir: [/usr/local/src/postfix-2.6.5]/tmp


Config_directory: [/etc/postfix]


Daemon_directory: [/usr/libexec/postfix]


Command_directory: [/usr/sbin]


Queue_directory: [/var/spool/postfix]


Sendmail_path: [/usr/sbin/sendmail]


Newaliases_path: [/usr/bin/newaliases]


Mailq_path: [/usr/bin/mailq]


Mail_owner: [postfix]


Setgid_group: [postdrop]


Html_directory: [no]/var/www/postfix_html


Manpages: [/usr/local/man]


Readme_directory: [no]


Run/usr/bin/newaliases to generate a new alias file, which improves the postfix efficiency.


[Root @ host postfix-2.8.2] #/usr/bin/newaliases


2. Perform some basic configurations, test and start postfix, and send emails.


# Vi/etc/postfix/main. cf


To manage the shutdown of the postfix service, create a script and copy the control script of the postfix rpm package.


[Root @ host ~] # Cd/tmp/


[Root @ host tmp] # mkdir abc


[Root @ host tmp] # cd abc/


[Root @ host abc] # cp/mnt/cdrom/Server/postfix-2.3.3-2.1.el5_2.i386.rpm ./


[Root @ host abc] # rpm2cpio postfix-2.3.3-2.1.el5_2.i386.rpm | cpio-id


Edit the postfix configuration file


[Root @ host init. d] # vim/etc/postfix/main. cf


Configure email server relay


Test email sending


Enable the rycus-sasl-based authentication function for postfix.


Vim/etc/postfix/main. cf


Add authentication function



4. Install Courier authentication library


[Root @ host ~] # Tar jxvf courier-authlib-0.63.0.tar.bz2-C/usr/local/src/


[Root @ host ~] # Cd/usr/local/src/courier-authlib-0.63.0/


[Root @ mail courier-authlib-0.63.0] #./configure \


> -- Prefix =/usr/local/courier-authlib \


> -- Sysconfdir =/etc \


> -- With-authmysql \


> -- With-mysql-libs =/usr/local/mysql/lib \


> -- With-mysql-nodes des =/usr/local/mysql/include \


> -- 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.0] # make


[Root @ mail courier-authlib-0.63.0] # make install


[Root @ mail courier-authlib-0.63.0] # chmod 755/usr/local/courier-authlib/var/spool/authdaemon


[Root @ mail courier-authlib-0.63.0] # cp/etc/authdaemonrc. dist/etc/authdaemonrc


[Root @ mail courier-authlib-0.63.0] # cp/etc/authmysqlrc. dist/etc/authmysqlrc


[Root @ mail etc] # vim/etc/authdaemonrc


[Root @ mail etc] # vim/etc/authmysqlrc


[Root @ mail etc] # cd/usr/local/src/courier-authlib-0.63.0/


[Root @ mail courier-authlib-0.63.0] # cp courier-authlib.sysvinit/etc/init. d


# Cp courier-authlib.sysvinit/etc/init. d/courier-authlib


# Chmod 755/etc/init. d/courier-authlib


# Chkconfig -- add courier-authlib


# Chkconfig -- level 2345 courier-authlib on



# Echo "/usr/local/courier-authlib/lib/courier-authlib">/etc/ld. so. conf. d/courier-authlib.conf


# Ldconfig-v


Start the service


[Root @ mail etc] # service courier-authlib start


Starting Courier authentication services: authdaemond


Create the directory where the virtual user mailbox is located, and grant its permission to the postfix User:


# Mkdir-pv/var/mailbox


# Chown-R postfix/var/mailbox


Next, reconfigure SMTP authentication and edit/usr/local/lib/sasl2/smtpd. conf to make sure it is the following content:


Pwcheck_method: authdaemond


Log_level: 3


Mech_list: PLAIN LOGIN


Authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket


5. Enable postfix to support virtual domains and virtual users


1. edit/etc/postfix/main. cf and add the following content:


2. Use extmail. SQL and init. SQL In the docs directory under the extman source code directory to create a database:


[Root @ mail ~] # Tar-zxvf extman-1.1.tar.gz


[Root @ mail ~] # Music extman-1.1/var/www/extsuite/extman


Because of the mysql version. Before importing the database, we need to perform extmail. SQL modification, extmail. delete the text line in the SQL statement, delete the line TYPE = MyISAMCOMMENT = 'extmail-Virtual mailboxes', and change line 87 to can_signup varchar (255 ).


[Root @ mail docs] # mysql-u root-p <extmail. SQL


Import and initialize the init. SQL script to the mysql database


[Root @ mail docs] # mysql-u root-p <init. SQL


View database verification after import


6. Configure dovecot

Already installed


Configure dovecot


[Root @ mail Server] # vim/etc/dovecot. conf


Configuration file used to create a connection between dovcot and mysql


[Root @ mail Server] # vim/etc/dovecot-mysql.conf


Set to boot


[Root @ mail Server] # chkconfig dovecot on



7. Install the Extmail-1.2 (first install httpd)


[Root @ mail ~] # Mkdir-pv/var/www/extsuite


[Root @ mail ~] # Tar-zxvf extmail-1.2.tar.gz


[Root @ mail ~] # Music extmail-1.2/var/www/extsuite/extmail


Cp/var/www/extsuite/extmail/webmail. cf. default/var/www/extsuite/extmail/webmail. cf


Edit configuration file


Apache configuration


Modifying the cgi execution file is a postfix user.


[Root @ mail extmail] # chown-R postfix. postfix/var/www/extsuite/extmail/cgi/


4. Dependency Solution


[Root @ mail ~] # Tar-zxvf Unix-Syslog-0.100.tar.gz-C/usr/local/src/


[Root @ mail ~] # Cd/usr/local/src/Unix-Syslog-0.100/


[Root @ mail Unix-Syslog-0.100] # perl Makefile. PL


[Root @ mail Unix-Syslog-0.100] # make


[Root @ mail Unix-Syslog-0.100] # make install


Restart the httpd server


8. Configure Extman-1.1


[Root @ mail ~] # Music extman-1.1/var/www/extsuite/extman


[Root @ mail ~] # Cp/var/www/extsuite/extman/webman. cf. default/var/www/extsuite/extman/webman. cf


[Root @ mail ~] # Vim/var/www/extsuite/extman/webman. cf


12 SYS_MAILDIR_BASE =/var/mailbox


21 SYS_CAPTCHA_ON = 0


127 SYS_MYSQL_USER = webman


128 SYS_MYSQL_PASS = webman


129 SYS_MYSQL_DB = extmail


130 SYS_MYSQL_HOST = localhost


131 SYS_MYSQL_SOCKET =/tmp/mysql. sock


In the master configuration file of apache, the virtual host section of extmail. Add two rows


Create a temporary directory for running and modify permissions


[Root @ mail ~] # Mkdir-pv/tmp/extman


Mkdir: created directory '/tmp/extman'


[Root @ mail ~] # Chown postfix. postfix/tmp/extman


Restart the apache server.


Login test Default Administrator Account: root@extmail.org password: extmail * 123 *


Http: // 10.1.1.100



This article from the "Mu xiaohao-51CTO" blog, please be sure to keep this source http://muxiaohao.blog.51cto.com/7208070/1314581


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.