Set up an email server

Source: Internet
Author: User

 

Yum install gcc-C ++

/* PCRE requires C ++ */
Tar-zxvf pcre-7.9.tar.gz
CD pcre-7.9
./Configure -- prefix =/usr/local/pcre-7.9 -- libdir =/usr/local/lib/PCRE -- export dedir =/usr/local/include/PCRE -- Build = i686-pc-linux-gnu
Make
Make install
Vim/etc/lD. So. conf
Write/usr/local/lib/PCRE
Then run ldconfig

Yum install MySQL mysql-server mysql-devel db4-devel OpenSSL GCC libxml2 libxml2-devel

/* If it is not installed, the Postfix compilation Error */
Yum install PCRE-devel

/* Create a user */
Groupadd-G 2001 Postfix
Useradd-G postfix-u 1001-S/sbin/nologin-M Postfix
Groupadd-G 2002 postdrop
Useradd-G postdrop-u 2002-S/bin/false-M postdrop

/* Install Postfix */
Tar-zxvf postfix-2.5.6.tar.gz
CD postfix-2.5.6

Make makefiles ccargs = '-duse_sasl_auth-ddef_server_sasl_type = \ "Dovecot \"\
-Dhas_pcre-dhas_mysql \
-I/usr/include/-I/usr/local/include-I/usr/include/MySQL /'\
Auxlibs = '-L/usr/local/lib-L/usr/lib/MySQL-lmysqlclient-lpcre'

Make
Make install (Press ENTER for all questions about make install by default)

/* Start MySQL */
Service mysqld start

/* Import and initialize extmail (you can change the password )*/
Tar-zxvf extman-1 \ [1 \] \ [1 \ 2.16.0.0.tar.gz
CD extman-1.0.0/docs/
Mysql-u root-P <extmail. SQL
Mysql-u root-P <init. SQL
CP MySQL _ *. Cf/etc/Postfix/

/* Install Dovecot */
Tar-zxvf dovecot-1.1.14.tar.gz
CD dovecot-1.1.14
./Configure -- prefix =/usr/local/Dovecot -- sysconfdir =/etc/Dovecot -- With-SQL-drivers -- With-mysql -- With-SSL = OpenSSL
Make
Make install

/* Configure Dovecot */
CD/etc/Dovecot
CP dovecot-example.conf Dovecot. conf
VI Dovecot. conf

Base_dir =/var/run/Dovecot
Protocols = IMAP IMAPs POP3 pop3s
Listen = *
Disable_plaintext_auth = No
Ssl_disable = Yes
Mail_location = maildir:/var/vmail/% d/% N/maildir
Pop3_uidl_format = % 08xu % 08xv

Auth default {
...
Mechanical ISMs = plain login digest-md5 cram-md5

# Remove comments
Passdb SQL {
ARGs =/etc/Dovecot/dovecot-sql.conf
}
...
# Remove comments
Userdb SQL {
ARGs =/etc/Dovecot/dovecot-sql.conf
}
...
Socket listen {
...
Client {
Path =/var/spool/Postfix/private/auth
Mode = 0660
User = Postfix
Group = Postfix
}
}
}
# Comment out
# Passdb Pam {
...
#}

/* Configure the dovecot-sql.conf (extmail. SQL imports the data )*/
CP dovecot-sql-example.conf dovecot-sql.conf
VI dovecot-sql.conf

Driver = MySQL
Connect = host = localhost dbname = extmail user = extmail Password = extmail
# MD5-CRYPT is a password-saving method compatible with extmail
Default_pass_scheme = MD5-CRYPT

# Dovecot SQL statements that provide password verification for SASL, POP3, and other services
Password_query = select username as user, password as password \
From mailbox where username = '% U' and active = '1'

# Dovecot provides the SQL statements required by the POP3/IMAP service
User_query = \
Select maildir as home, 1001 as uid, 2001 as GID \
From mailbox where username = '% U' and active = '1'

/* Create a symbolic link */
Ln-S/usr/local/Dovecot/sbin/Dovecot/usr/bin/Dovecot
/* Create a Dovecot user */
Useradd-S/bin/false-D/dev/null Dovecot

/* Configure Postfix */
MV/etc/aliases. Old
Ln-S/etc/Postfix/aliases/etc/aliases
/Usr/bin/newaliases

Vim/etc/Postfix/Main. cf

Myhostname = mail.luilai.cn
Mydomain = luilai.cn
Myorigin = $ mydomain
Mydestination = $ myhostname localhost. $ mydomain
Mynetworks = 192.168.1.0/24 127.0.0.0/8
Inet_interfaces = all
# Note that this indicates that the mail of the host system user is delivered to the mbox file (mailbox format) in the user directory)
Home_mailbox = mbox

Sendmail_path =/usr/sbin/sendmail
Newaliases_path =/usr/bin/newaliases
Mailq_path =/usr/bin/mailq
Setgid_group = postdrop
Html_directory = No
Manpage_directory =/usr/local/man
Sample_directory =/etc/Postfix

#================================ Vritual mailbox settings ==================== ============
Virtual_mailbox_base =/var/vmail/
Virtual_mailbox_maps = MYSQL:/etc/Postfix/mysql_virtual_mailbox_maps.cf
Virtual_mailbox_domains = MYSQL:/etc/Postfix/mysql_virtual_domains_maps.cf
Virtual_alias_domains =
Virtual_alias_maps = MYSQL:/etc/Postfix/mysql_virtual_alias_maps.cf
Virtual_uid_maps = static: 1001
Virtual_gid_maps = static: 2001
Virtual_transport = Virtual

#================================== Quota ======================= ======
Message _ size_limit = 52428800
Mailbox_size_limit = 209715200
Virtual_mailbox_limit = 209715200
Virtual_create_maildirsize = Yes
Virtual_mailbox_extended = Yes
Virtual_mailbox_limit_maps = MYSQL:/etc/Postfix/mysql_virtual_mailbox_limit_maps.cf
Virtual_mailbox_limit_override = Yes
Virtual_overquota_bounce = Yes

#================================ Sasl esmtp authenticat ========================== =
Smtpd_sasl_auth_enable = Yes
Smtpd_sasl_type = Dovecot
# Smtpd_sasl_path note that this is the SASL path of Dovecot, which corresponds to the SASL path in Dovecot. conf.
Smtpd_sasl_path = private/auth
Broken_sasl_auth_clients = Yes
Smtpd_recipient_restrictions = permit_mynetworks,
Permit_sasl_authenticated,
Reject_invalid_hostname,
Reject_non_fqdn_hostname,
Reject_unknown_sender_domain,
Reject_non_fqdn_sender,
Reject_non_fqdn_recipient,
Reject_unknown_recipient_domain,
Reject_unauth_pipelining,
Reject_unauth_destination

Readme_directory = No
Command_directory =/usr/sbin
Daemon_directory =/usr/libexec/Postfix
Queue_directory =/var/spool/Postfix
Mail_owner = Postfix
Data_directory =/var/lib/Postfix

/* Add to start */
Vim/etc/rc. d/rc. Local
/Etc/rc. d/init. d/mysqld start
/Usr/bin/newaliases
/Usr/local/Dovecot/sbin/Dovecot
/Usr/sbin/Postfix start

Yum install libpng libxslt-devel FreeType-devel Gd-devel libmcrypt-devel

/* Install Apache */
Mkdir/var/www/webroot
CD httpd-2.2.11
. /Configure -- prefix =/usr/local/Apache -- enable-modules = so -- enable-Rewrite -- enable-suexec -- With-suexec-docroot =/var/www/--- suexec-caller = daemon
Make; make install

/* Check whether suexec is correctly installed */
/Usr/local/Apache/bin/suexec-V

/* Configure Apache */
Vim/usr/local/Apache/CONF/httpd. conf

Servername http://www.example.com/
Serveradmin abinxm@gmail.com
DocumentRoot "/var/www/webroot"
# Deny from all
Allow from all
<Directory "/var/www/webroot">
Directoryindex index.html index. php index.htm
Addtype application/X-httpd-PHP. php
Addtype application/X-httpd-PHP-source. PHPs

/* Install PHP */
CD php-5.2.9
. /Configure -- prefix =/usr/local/PhP5 -- with-apxs2 =/usr/local/Apache/bin/apxs -- With-mysql =/usr/lib/MySQL/-- enable-FTP -- With-libxml-Dir =/usr/lib/-- With-expat-Dir =/usr/lib -- With-XSL =/usr/lib/-- enable-XSLT --- GD =/usr/-- With-JPEG-Dir =/usr/lib/-- With-zlib-Dir =/usr/lib/-- With-PNG -- With-FreeType-Dir = /usr/lib/-- enable-mbstring -- With-mcrypt =/usr/lib/
Make; make install

CD/usr/local/Apache/modules/
Chmod-r 755.
Chcon-T texrel_shlib_t/usr/local/Apache/modules/libphp5.so

/* Firewall settings */
Vim/etc/sysconfig/iptables
Open Port 25, 110, and 143
-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 80-J accept

/Etc/rc. d/init. d/iptables restart

/* Install phpMyAdmin */
Unzip phpMyAdmin-3.1.3-all-languages.zip
CD phpMyAdmin
CP config. sample. Inc. php config. Inc. php

Vim config. Inc. php

$ Cfg ['blowfish _ secret'] = 'liulaiabinxm ';

/* Change the MySQL password */
Mysqladmin-u root-P password 'new password'

/* Extmail related package */

Tar-zxvf Time-HiRes-1.9719.tar.gz
CD time-hires-1.9719
Perl makefile. pl
Make
Make Test
Make install

Tar-zxvf File-Tail-0.99.3.tar.gz
CD file-tail-0.99.3
Perl makefile. pl
Make
Make Test
Make install

Yum install libart_lgpl-devel
Yum install TCL-devel

Tar-zxvf rrdtool-1.2.30.tar.tar
CD rrdtool-1.2.30
./Configure -- prefix =/usr/local/rrdtool
Make; make install
Make site-perl-install

Tar-zxvf GD-2.41.tar.gz
CD GD-2.41
Perl makefile. pl
Make
Make Test
Make install

Tar-zxvf libart_lgpl-2.3.20.tar.gz
CD libart_lgpl-2.3.20
./Configure
Make; make install

Tar-zxvf Unix-Syslog-1.1.tar.gz
CD Unix-Syslog-1.1
Perl makefile. pl
Make
Make Test
Make install

/* Start the graphic log */
CP-r/var/www/extsuite/extman/addon/mailgraph_ext // usr/local/mailgraph_ext/
Ln-SV/usr/local/rrdtool/lib/perl/5.8.8/i386-linux-thread-multi/rrds. PM/usr/lib/perl5/5.8.8
Ln-SV/usr/local/rrdtool/lib/perl/5.8.8/i386-linux-thread-multi/auto/rrds. So/usr/lib/perl5/5.8.8/i386-linux-thread-multi/

/Usr/local/mailgraph_ext/mailgraph-init start
/Usr/local/mailgraph_ext/qmonitor-init start

/* Add to start */
Vim/etc/rc. d/rc. Local

/Usr/local/mailgraph_ext/mailgraph-init start
/Usr/local/mailgraph_ext/qmonitor-init start

Mkdir/tmp/extman
Chown-r Postfix. Postfix/tmp/extman/

CD/var/WWW
Chown-r Postfix. Postfix.

/* Set Apache */
Vim/usr/local/Apache/CONF/httpd. conf

Namevirtualhost *: 80
<Virtualhost *: 80>
# Servername mail.example.com
Servername mail.luilai.cn
DocumentRoot/var/www/webroot/

ScriptAlias/extman/cgi/var/www/extman/cgi
Alias/extman/var/www/extman/html

ScriptAlias/extmail/cgi/var/www/extmail/cgi
# Dispatch. fcgi
Alias/extmail/var/www/extmail/html

Alias/PHPmyAdmin/var/www/webroot/PHPmyAdmin/
Suexecusergroup Postfix
</Virtualhost>

Mkdir/var/vmail
Chown-r Postfix. Postfix/var/vmail/

Modify webman. CF and webmail. cf
Configure the path sys_config sys_langdir sys_templdir
Sys_maildir_base =/var/vmail/consistent with postfix

Vim/var/www/extman/webman. cf
# Verification Code
# Sys_captcha_on = 1
Sys_captcha_on = 0

Vim/var/www/extmail/webmail. cf

------------------------------------------------

Then add maildrop to replace the original MDA ~ Google many ways

Extmail then provides the filtering function, automatic reply, and blacklist and whitelist.

Maildrop has its own syntax structure, such as xfilter "PHP-f. PHP "to call external programs, written in. in the mailfilter file, control the calling of certain programs when receiving emails, or filter and reply emails. Of course, MDA also has other alternatives.

It is important to set permissions during server setup. Otherwise, errors may occur frequently. Some problems may occur due to the lack of a module.

Courier-authlib is used for maildrop persistent layer access.

 

 

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.