Free Postfix Email System Solution
Why choose Moges?
• Successfully deployed email systems for over 100 manufacturing companies.
• Local team in Kunshan, offering on-site service within 2 hours.
• Provides comprehensive installation documentation, significantly reducing configuration time.
• Supports subsequent upgrades to a highly available cluster solution
1、System Objectives
Maildir email storage format
SMTP authentication
Separate email addresses and system accounts.
Multi-domain support
Web management account, aliases, domain information, etc.
pop3/imap support
Webmail support
Integrates with MySQL database
2、TODO
Integrated spam filtering
Integrated Antivirus
Project: xx Company Email System Solution
Date:
Author:
1、System Objectives
Maildir email storage format
SMTP authentication
Separate email addresses and system accounts.
Multi-domain support
Web management account, aliases, domain information, etc.
pop3/imap support
Webmail support
Integrates with MySQL database
2、TODO
Integrated spam filtering
Integrated Antivirus
3、System Architecture
+---------------------------------------------------+
| |
| 25/25 25/25 110/993 143/995 80/443 |
| Incoming Outgoing POP3 IMAP WEB-MAIL |
| / / / / / |
| || || || || || |
| / / / / / |
+-------------------+---------------+---------------+
| Postfix | | Squirrelmail |
| | +---------------+
| | Courier-imap |
| +-----------+-------------------------------+
| + Courier-authlib +
| |-------------------------------------------|
| | Cyrus-SASL |
|-------+-------------------------------------------+
| MySQL |
+---------------------------------------------------+
4、System Installation
The operating system uses Debian 3.1 (Sarge). It does not include pre-installed basic libraries and software such as GCC, Make, DB, glibc, etc. All required software for the email system are installed using the `apt-get install` package names.
mail~#apt-get install gcc make
mail~#apt-get install libdb4-*
mail~#apt-get install curses*
mail~#apt-get install termcap*
..............
4.1、mysql
mail~#wget http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-4.1.12.tar.gz/from/http://mysql.cbn.net.id/
mail~#groupadd mysql
mail~#useradd -g mysql mysql
mail~#tar zxvf /usr/src/mail/mysql-4.1.12.tar.gz -C /tmp
mail~#cd /tmp/mysql-4.1.12
mail~#./configure --prefix=/opt/mysql --localstatedir=/opt/mysql/data --with-unix-socket-path=/tmp/mysql.sock --with-mysql-user=mysql --with-charset=gb2312 --with-extra-charsets=all
mail~#make
mail~#make install
mail~#chown -R mysql:mysql /opt/mysql/data/
If the /opt/mysql/var/mail.err file does not exist, create it manually.
mail~#mkdir /opt/mysql/var
mail~#touch /opt/mysql/var/mail.err
mail~#/opt/mysql/bin/mysqld_safe --user=mysql & #Start the MySQL service
mail~#/opt/mysql/bin/mysql #Start the MySQL client
mail~#vi /etc/ld.so.conf, add
/opt/mysql/lib/mysql
mail~#ldconfig
mail~#cp /opt/mysql/share/mysql/mysql.server /etc/init.d/mysqld
mail~#chmod 755 /etc/init.d/mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc3.d/S52mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc5.d/S52mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc0.d/K25mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc1.d/K25mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc2.d/K25mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc4.d/K25mysqld
mail~#ln -s /etc/init.d/mysqld /etc/rc6.d/K25mysqld
4.2、apahce
mail~#wget http://apache.justdn.org/httpd/apache_1.3.33.tar.gz
mail~#goupadd www
mail~#useradd -g www -d /dev/null -s /bin/false www
mail~#tar zxvf /usr/src/mail/apache_1.3.33.tar.gz -C /tmp
mail~#cd /tmp/apache_1.3.33
mail~#./configure --prefix=/opt/apache --enable-module=rewrite --enable-shared=rewrite --enable-module=proxy --enable-shared=proxy --enable-module=so --server-uid=www --server-gid=www
mail~#make
mail~#make install
mail~#/opt/mysql/var# /opt/apache/bin/apachectl start #Start the Apache server
mail~#cd /opt/apache/bin/
mail~#cp apachectl /etc/init.d/httpd
mail~#cd /etc/init.d/
mail~#chmod 755 httpd
mail~#ln -s /etc/init.d/httpd /etc/rc3.d/S51httpd
mail~#ln -s /etc/init.d/httpd /etc/rc5.d/S51httpd
mail~#ln -s /etc/init.d/httpd /etc/rc0.d/K15httpd
mail~#ln -s /etc/init.d/httpd /etc/rc1.d/K15httpd
mail~#ln -s /etc/init.d/httpd /etc/rc2.d/K15httpd
mail~#ln -s /etc/init.d/httpd /etc/rc4.d/K15httpd
mail~#ln -s /etc/init.d/httpd /etc/rc6.d/K15httpd
4.3、php4
mail~#wget http://cn2.php.net/get/php-4.3.11.tar.gz/from/cn.php.net/mirror
mail~#tar zxvf /usr/src/mail/php-4.3.11.tar.gz -C /tmp
mail~#cd /tmp/php-4.3.11
mail~#./configure --prefix=/opt/php4 --with-xml --with-mysql=/opt/mysql --with-mysql-sock=/tmp/mysqld.php4.sock --with-apxs=/opt/apache/bin/apxs
mail~#make
mail~#make install
mail~#cp php.ini-dist /opt/php4/lib/php.ini
Modify /opt/apache/conf/httpd.conf, add PHP4 support, and add the following content:
#php 4
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Also modify
DirectoryIndex index.html
For
DirectoryIndex index.html index.php
mail~#vi /opt/apache/htdocs/test.php, the content is as follows:
mail~#/opt/mysql/var# /opt/apache/bin/apachectl restart # Restart the Apache server
Use Lynx or a common browser such as IE, Firefox, to access http://ip/test.php and view the PHP information page.
4.4、openssl
mail~#wget http://www.openssl.org/source/openssl-0.9.8.tar.gz
mail~#tar zxvf /usr/src/mail/openssl-0.9.8.tar.gz -C /tmp
mail~#cd /tmp/openssl-0.9.8
mail~#./configure --prefix=/opt/openssl
mail~#make
mail~#make install
mail~#ln -s /opt/openssl/include/openssl /usr/include/openssl
4.5、cyrus-sasl2
mail~#wget http://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.21.tar.gz
mail~#tar zxvf /usr/src/mail/cyrus-sasl-2.1.21.tar.gz -C /tmp
mail~#cd /tmp/cyrus-sasl-2.1.21
mail~#./configure --prefix=/opt/sasl2 --enable-login --enable-plain --enable-sql --enable-pwcheck --disable-anon --disable-digest --with-mysql=/opt/mysql --with-mysql-includes=/opt/mysql/include/mysql --with-mysql-libs=/opt/mysql/lib/mysql --with-saslauthd=/var/run
mail~#make
If the following error occurs:
auth_getpwent.c:48:20: des.h: No such file or directory
make[3]: *** [auth_getpwent.o] Error 1
make[3]: Leaving directory `/tmp/cyrus-sasl-2.1.21/saslauthd'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/tmp/cyrus-sasl-2.1.21/saslauthd'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/cyrus-sasl-2.1.21'
make: *** [all] Error 2
Modify the variables in the CFLAGS within the Makefiles located at /tmp/cyrus-sasl-2.1.21/saslauthd/ to include -I/opt/openssl/include/openssl
Or directly
mail~#cp /tmp/cyrus-sasl-2.1.21/mac/libdes/public/des.h /tmp/cyrus-sasl-2.1.21/
mail~#make
mail~#make install
mail~#vi /etc/ld.so.conf # Add the following content
/usr/lib/sals2
/opt/sasl2/lib/sasl2
mail~#ldconfig
4.6、postfix
mail~#wget http://postfix.it-austria.net/releases/official/postfix-2.2.4.tar.gz
mail~#groupadd postfix
mail~#ueradd -g postfix -d /dev/null -s /bin/false postfix
mail~#make makefiles 'CCARGS=-DHAS_MYSQL -I/opt/mysql/include/mysql -DUSE_SASL_AUTH -I/opt/sasl2/include/sasl' 'AUXLIBS=-L/opt/mysql/lib/mysql -lmysqlclient -lm -lz -L/opt/sasl2/lib/sasl2 -lsasl2'
mail~#make install #Press Enter to proceed with the default settings.
mail~#vi /etc/init.d/postfix
#!/bin/sh
start() {
#Start daemons.
echo -n "Starting postfix: "
/usr/sbin/postfix start
}
stop() {
#Stop daemons.
echo -n "Shutting down postfix: "
/usr/sbin/postfix stop
}
reload(){
echo -n "Reloading postfix: "
/usr/sbin/postfix reload
}
restart(){
stop
start
}
abort(){
/usr/sbin/postfix abort
}
flush(){
/usr/sbin/postfix flush
}
check(){
/usr/sbin/postfix check
}
case $1 in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
abort)
abort
;;
flush)
flush
;;
check)
check
;;
*)
echo "Usage: postfix {start|stop|restart|reload|abort|flush|check}"
esac
mail~#chmod 755 /etc/init.d/postfix
mail~#ln -s /etc/init.d/postfix /etc/rc3.d/S53postfix
mail~#ln -s /etc/init.d/postfix /etc/rc5.d/S53postfix
mail~#ln -s /etc/init.d/postfix /etc/rc0.d/K35postfix
mail~#ln -s /etc/init.d/postfix /etc/rc1.d/K35postfix
mail~#ln -s /etc/init.d/postfix /etc/rc2.d/K35postfix
mail~#ln -s /etc/init.d/postfix /etc/rc4.d/K35postfix
mail~#ln -s /etc/init.d/postfix /etc/rc6.d/K35postfix
4.7、courier-authlib
mail~#wget http://www.courier-mta.org/beta/courier-authlib/courier-authlib-0.56.20050709.tar.bz2
mail~#su - wxt
wxt@mail:~$ tar xjvf /usr/src/mail/courier-authlib-0.56.20050709.tar.bz2 -C /tmp
wxt@mail:~$cd /tmp/courier-authlib-0.56.20050709/
wxt@mail:~$./configure --with-authmysql=yes --with-mailuser=www --with-mailgroup=www
--with-mysql-libs=/opt/mysql/lib/mysql --with-mysql-includes=/opt/mysql/include
/mysql --prefix=/opt/courier-authlib
wxt@mail:~$make
wxt@mail:~$exit
mail~#make install
4.8、courier-imap
mail~#wget http://www.courier-mta.org/beta/imap/courier-imap-4.0.3.20050702.tar.bz2
mail~#tar zxvf courier-imap-4.0.3.20050702.tar.bz2
mail~#su - wxt
wxt@mail:~$./configure --enable-unicode=utf-8,iso-8859-1,gb2312,gbk,gb18030,big5 --prefix=/opt/courier-imap --disable-root-check --with-trashquota --with-dirsync
If the operation fails, the following error message will be displayed.
configure: WARNING: === Courier authentication library not found.
configure: WARNING: === You need to download and install
configure: WARNING: === http://www.courier-mta.org/download.php#authlib first.
configure: WARNING: === If courier-authlib is installed in a non-default
configure: WARNING: === directory, set the COURIERAUTHCONFIG environment
configure: WARNING: === variable to the full path to the courierauthconfig
configure: WARNING: === binary and rerun this configure script.
configure: WARNING:
configure: error: courierauthconfig not found
Set the variable COURIERAUTHCONFIG