Postfix Cyrus-IMAP Cyrus-Sasl MySQL IMP Full Guide
Creation time: 2003-10-13
Article properties: reprint
Article submission:
Shel0Ter (shel0ter_at_21cn.com)
Fully introduced the method of using Postfix to establish a complete mail server, including SMTP authentication, IMAP authentication, and Webmail et al., The article is complete and comprehensive, but you can use it.
Author: Wang Xingyu mailto: wxy@cngnu.org
Version: 0.41
Copyright: GPL
table of Contents
1 Overview
1.1. Purpose
1.2. Update history
1.3. Todo
1.4.
2. System function
3. Basic premise of system
4. Configure MySQL
4.1. Run
4.2. Test
4.3. Configuration
5. Install PAM_MYSQL
5.1. Download
5.2. Compilation and installation
5.3. Configuration
6. Install Cyrus-SASL
6.1. Download
6.2. Compilation and installation
6.3. Configuration
6.4. Run
7. Install Postfix
7.1. Download
7.2. Compilation and installation
7.3. Configuration
7.4. Run
7.5. Test
8. Install Cyrus-IMAP
8.1. Download
8.2. Compilation and installation
8.3. Configuration
8.4. Run
8.5. Test
9. Install IMP
9.1. Download
9.2. Configuring Apache / PHP
9.3. Configuring Horde
9.4. Configuring IMP
9.5. Configuring Turba
9.6. Test IMP
10. Others
10.1. Start the script
10.2. Overall test
-------------------------------------------------- ------------------------------
1 Overview
1.1. Purpose
This article tries to describe how to install a fully functional mail system on a Linux platform. Here we do SMTP servers with Postfix, CYRUS-IMAP makes POP3 / IMAP4 servers, verify and authorize users stored in the MySQL database via Cyrus-SASL, and use IMP to provide a perfect webmail interface.
The design goal of this mail system is to provide an expandable and multi-functional mail system.
The latest version of this article can be found here:
Format URL
Simplified Chinese / HTML
http://www.cngnu.org/technology/postfix_i.html
Traditional Chinese / HTML
http://www.cngnu.org/technology/postfix_i.tw.html
Simplified Chinese / Text
http://www.cngnu.org/technology/postfix_i.txt
Traditional Chinese / Text
http://www.cngnu.org/technology/postfix_i.tw.txt
Issue about the technical problems involved in this article.
Http://www.chinaunix.net/forum/viewforum.net/forum/viewforum.php?f=14 Mail version, I will reply as soon as possible.
The copyright of this article follows the GPL, which can be arbitrarily spread without removing copyright information and indicating the modification.
1.2. Update history
2002-05-21 First release, version 0.20.
2002-08-13 Fix some errors, version 0.21.
2002-08-23 Fix some errors, version 0.22.
2002-09-12 Tests on Redhat Linux Advance Server V2.1, fixes some errors, version 0.30.
2002-12-12 Fixed some errors, adding the contents of the IMP section, version 0.31.2003-01-30 Fixed some errors, adding the contents of the non-text password, version 0.32.
2003-02-05 Fixed some mistakes, version 0.33
2003-03-26 Using SASL V2 and CYRUS-IMAP 2, supporting new Linux distributions using DB4, such as Redhat 8.0 and Mandrake 9.0, and use Redhat 8.0 as an exemplary platform. Fixed some errors, version 0.40.
2003-03-28 Fixed some mistakes, especially bjchenxu, version 0.41.
1.3. Todo
Add mailing list function
Increase the content of the SSL section
Increase the content of the virtual domain part
Translation: I hope that the ability to have the ability can translate this article as English, so foreign friends can also see
1.4.
Thank you for your fingering.
Reference documentation:
http://www.delouw.ch/linux/postfix-cyrus-web-cyradm-howto/html/index.html. At the beginning of this article, refer to this article, this article is also constantly updating, you can also look at it.
2. System function
System logical structure:
----------------------------------- -
| | |
| 25/25 25/25 110/993 143/995 80/443 |
| Incoming outgoing pop3 IMAP web-mail |
| / / / / / / / /
| | || || || || || |
| / / / / / / / /
------------------------------------- -
Postfix | | IMP |
| | ---------------
| | CYRUS-IMAP |
| -------------------------------------------
| | CYRUS-SASL |
| -------------------------------------------
| | Saslauthd |
| -------------------------------------------
| | PAM |
| -------------------------------------------
| | PAM_MYSQL | ------- ----------------------------------- ------
| Mysql |
----------------------------------- -
The entire system-external interface consists of several parts, using SMTP, used to recruit POP3 and IMAP, as well as a web interface to use the system. There is no management tool for the web interface here, and you need to develop it according to actual needs.
Mysql as the core of storing data in the system, which stores the user's information. This information is not only used for POP3 / IMAP and SMTP AUTH, but also provides list and forwarding functions of local recipients for Postfix.
certified process is more cumbersome. The entire authentication is made through Cyrus-SASL, and the authentication needs are listened by running a daemon saslauthd. Saslauthd This uses a PAM authentication to find the mysql database through the PAM_MYSQL plugin.
3. Basic premise of system
This article focuses on the Target platform for Linux systems, supports most Linux platforms such as Redhat 7.x / 8.x, Mandrake 8.x / 9.x, etc., theoretically supports other Linux distributions, and even other Unix system.
Here is a platform for Redhat Linux V 8.0.
In addition to the basic operating system part, the platform is equipped with RPM:
First, GCC:
1. GCC-3.2-7
2. GCC-C - 3.2-7
Two, DB3:
db4-deb4.0.14-14
db4-4.0.14-14
3. DB4-UTILS-4.0.14-14
Three, PAM:
1. PAM-0.75-40
pam-devel-0.75-40
Four, mysql:
mysql-3.23.52-3
mysql-server-3.23.52-3
mysql-deb-3.23.52-3
5, IMP related:
httpd-2.0.40-8
httpd-devel-2.0.40-8
2002. GetText-0.11.4-3
3. IMAP-DEVEL-2001A-15
4. KRB5-LIBS-1.2.5-6
5. KRB5-Devel-1.2.5-6
6. OpenSSL-0.9.6B-29
7. OpenSSL-DEVEL-0.9.6B-29
If there is no system in the system, please install the RPM package or compile installation yourself. In addition, other parts needed to be compiled in the source code.
4. Configure MySQL
4.1. Run
The start command is as follows:
[root @mail root] # /etc/init.d/mysqld start
4.2. Test
After starting mySQL, first check the log / var / log / messages has error messages, then check the process, there should be the following process:
[root @mail root] # pstree | grep mysqld
| -SAFE_MYSQLD --- MySQLD --- MySQLD --- 2 * [mysqld]
Then check the port, there should be the following ports to open:
[root @mail root] # netstat -an | grep listen
TCP
After Mysql installation configuration, create a mail user database in MySQL and add a test user "Tester":
[root @mail root] # mysql mysql
Reading Table Information for Completion of Table and Column Names
You Can Turn Off this Feature To Get a Quicker Startup with -a
Welcome to the mysql monitor. Commands end with; or / g.
Your MySQL Connection ID IS 1 To Server Version: 3.23.52
Type 'help;' or '/ h' for help. Type '/ c' to clear the buffer.
Mysql> Create Database Mail;
Query Ok, 1 Row Affected (0.00 sec)
Mysql> Grant All on mail. * to mail @ localhost
odentified by "second";
Query Ok, 0 row affected (0.00 sec)
mysql> flush privileges;
Query Ok, 0 row affected (0.00 sec)
Mysql> Use mail;
Database change
Mysql> Create Table User
Username varchar (32) Not null default '',
word varchar (64) Not null default '',
not null default '
-> patition varchar (32) Not null default 'default',
1024 ',
"status tinyint not null default '1');
Query OK, 0 ROWS Affected (0.00 SEC)
Mysql> Create Index User On User (username, password, forward, status);
Query OK, 0 ROWS Affected (0.00 SEC)
Records: 0 Duplicates: 0 Warnings: 0
Mysql> Insert Into User (Username, Password, Forward) Values
-> ('Tester', '$ 1 $ Pi.wvgbx $ A3Duczbnby76jnzlqwqcq /', 'Tester');
Query Ok, 1 Row Affected (0.01 sec)
mysql> / q
BYE
The USER table of the above Mail database is used to save user information:
UserName and Password fields are user names and MD5-Crypt passwords. The encrypted password is used here for better security.
The Forward field is the same as UserName by default, in this case, the message is submitted to the local mailbox (because the postfix is different from the case case in the mailbox, "the difference in case can be eliminated; if the forward field is another User name or email address, the message is forwarded to other users or other email addresses. The STATUS field is used to indicate whether the user is valid, and a user can be disabled by modifying the value of 0.
5. Install PAM_MYSQL
5.1. Download
http://sourceforge.net/projects/pam-mysql/
[root @mail root] # CD / usr / src
[root @mail src] # wget
http://prdownloads.sourceforge.net/pam-mysql/pam_mysql-0.4.7.tar.gz
Note: If you cannot access the website to get PAM_MYSQL, please use the proxy server to access itself.
5.2. Compilation and installation
Compile PAM_MYSQL:
[root @mail src] # tar -zxf pam_mysql-0.5.tar.gz
[root @mail src] # CD PAM_MYSQL
Modify the source code of PAM_MYSQL.C and remove the debug message:
[root @ Mail Pam_Mysql] # vi 54 PAM_MYSQL.C
will be as follows:
#define debug
Modifications to:
/ * #define debug * /
Then compile:
[root @ mail pam_mysql] # Make
[root @ mail pam_mysql] # CP PAM_MYSQL.SO / LIB / SECURITY
In some cases, this compilation will report an error, but if compiled can generate the PAM_MYSQL.SO module, it is still possible.
5.3. Configuration
Create /etc/pam.d/mail, which is used to support Cyrus-IMAP IMAP authentication, POP authentication and postfix SMTP authentication:
[root @ mail pam_mysql] # cd /etc/pam.d
[root @ mail pam.d] # echo auth sufficient pam_mysql.so user = mail passwd = secret /
> host = localhost db = mail table = user userColumn = username passwdcolumn = password /
> CRYPT = 1> /etc/pam.d/mail
[root @ mail pam.d] # echo account required PAM_MYSQL.SO user = mail passwd = secret /
> host = localhost db = mail table = user userColumn = username passwdcolumn = password /
> CRYPT = 1 >> /etc/pam.d/mail
[root @mail pam.d] # echo auth sufficient pam_unix_auth.so >> /etc/pam.d/mail
[root @ Mail Pam.d] # echo account sufficient pam_unix_acct.so >> /etc/pam.d/mail
Here, the front two lines refer to authentication users through the MySQL database, and the back two lines refer to the basic way of UNIX (ie system users). Here we keep UNIX system authentication mode because we should manage the Cyrus-IMAP mailbox by system user Cyrus. However, you can also choose to put this administrative account Cyrus in the MySQL authentication database, just add a Cyrus user in the database. By giving different values to the above Crypt, you can use a variety of password storage:
Crypt = 0: Indicates the use of clear text to store the password. The benefits of such storage are simple, but not safe enough.
Crypt = 1: Represents the DES encryption method using the UNIX system to store. That is, the typical UNIX / etc / passwd (old system encryption port is stored here) or / etc / shadow stored in the encryption password stored in this here. There are two kinds of encryption, one is ordinary DES encryption, also called crypt (), this password is 13 long, the front two characters are encrypted seeds; there is a use of the MD5 algorithm to enhance, also Called MD5 CRYPT (), the encrypted seed of this password is 12 characters starting with $ 1, the password is uncertain.
Crypt = 2: Indicates the use of MySQL's SQL function password () encryption mode to store.
Crypt = 3: Indicates the use of MD5's hash method to store. This approach is not the same as MD5 CRYPT ().
Generally, if you use the Crypt = 1 mode if you migrate a virtual user using the database, you can use the Crypt = 1 mode, and the system automatically distinguishes two encryption passwords. If you need to develop a user to modify the password, the CRYPT function in C and Perl cannot support the MD5 CRYPT () password, and you need to use additional programming or modules to support.
Make a symbolic link /etc/pam.d/imap, which is used to support the IMAP authentication of Cyrus-IMAP:
[root @ mail pam.d] # [-f iMap] && mv iMap IMAP.ORIG
[root @ mail pam.d] # ln -s mail ouch
Create /etc/pam.d/pop, which is used to support Cyrus-IMAP POP3 authentication:
[root @ mail pam.d] # [-f pop] && mv pop pop.orig
[root @ mail pam.d] # ln -s mail POP
Create /etc/pam.d/smtp, which is used to support Postfix's SMTP Auth certification:
[root @ mail pam.d] # [-f smtp] && mv smtp SMTP.ORIG
[root @ Mail pam.d] # ln -s mail smtp
These files may already exist on the system, please rename or delete the original.
6. Install Cyrus-SASL
6.1. Download
http://asg.web.cmu.edu/cyrus/download/
[root @ mail pam.d] # CD / usr / src
[root @mail src] # wget
ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.12.tar.gz
6.2. Compilation and installation
Compile Cyrus-SASL, only supports the needs of PLAIN and Login authentication:
[root @mail src] # tar -zxvf cyrus-sasl-2.1.12.tar.gz
[root @ mail src] # cd cyrus-sasl-2.1.12
[root @mail cyrus-sasl-2.1.12] # ./configure --disable-sample /
> --disable-pwcheck --disable-cram --disable-digest /
> --disable-krb4 --disable-gssapi --disable-anon /
> --with-saslauthd = / var / run / saslauthd /
> --enable-plain --enable-login
[root @ mail cyrus-sasl-2.1.12] # MAKE
[root @ Mail Cyrus-SASL-2.1.12] # Make Install
[root @ Mail Cyrus-SASL-2.1.12] # [-d / usr / lib / sasl2] && mv / usr / lib / sasl2 /usr/lib/sasl2.orig
[root @ Mail Cyrus-SASL-2.1.12] # ln -s / usr / local / lib / sasl2 / usr / lib / sasl2
If SASL 2 has been installed, please remove these rpm or / usr / lib / sasl2.
Load Link Library:
[root @ mail cyrus-sasl-2.1.12] # echo / usr / local / lib >> /etc/ld.so.conf
[root @ mail cyrus-sasl-2.1.12] # echo / usr / local / lib / sasl2 >> /etc/ld.so.conf
[root @ Mail cyrus-sasl-2.1.12] # ldconfig
6.3. Configuration
Set Postfix Use SASL's SaslauthD certification daemon to support SMTP Auth certification:
[root @ mail cyrus-sasl-2.1.12] # echo pwcheck_method: saslauthd> /usr/lib/sasl2/smtpd.conf
SASL configuration does not use a standard SASL syntax, its configuration file is placed in /etc/imapd.conf, and the Cyrus-IMAP section is described in detail.
6.4. Run
Run the SaslauthD daemon and make it use PAM authentication mode to provide authentication information:
[root @ mail cyrus-sasl-2.1.12] # / usr / local / sbin / saslauthd -a pam
The authentication mechanism used throughout the system is more complicated. All applications (SMTP, IMAP, POP3, etc.) are authenticated by SASL V2 SASLAUTHD; SASLATHD is authenticated by user information stored in the mysql database with the PAM_MYSQL interface by the PAM mode supported by it. See the system structure above to understand the authentication process.
7. Install Postfix
7.1. Download
http://www.postfix.org/ftp-sites.html
[root @ mail cyrus-sasl-2.1.12] # CD / USR / SRC
[root @mail src] # wget
http://postfix.nergyBeam.com/source/official/postfix-2.0.7.tar.gz
7.2. Compilation and installation
If you have sendmail on your system, stop it and rename it files:
[root @mail src] # /etc/init.d/sendmail stop
[root @mail src] # mv / usr / bin / newaliases /usr/bin/newaliases.orig[Root@mail src] # mv / usr / bin / mailq /usr/bin/mailq.orig
[root @mail src] # mv / usr / sbin / sendmail /usr/sbin/sendmail.orig
Then add two groups: Postfix and Maildrop and a user: postfix
[root @mail src] # groupadd -g 12345 postfix
[root @ mail src] # groupadd -g 12346 PostDrop
[root @ mail src] # @ UserAdd -u 12345 -g 12345 -c postfix -m -d / no / where -s / no / shell postfix
The group and the user's ID here is the ID unused in the system.
Compile Postfix and support MySQL and SASL:
[root @mail src] # tar -xvzf postfix-2.0.7.tar.gz
[root @ mail src] # cd postfix-2.0.7
[root @mail postfix-2.0.7] # make -f makefile.init makefiles /
> 'Ccargs = -duse_sasl_auth -dhas_mysql -i / usr / include / mysql -i / usr / local / incrude / sasl' /
> 'Auxlibs = -l / usr / lib / mysql -l / usr / local / lib / sasl2 -lmysqlclient -lsasl2 -lz -lm'
[root @mail postfix-2.0.7] # make install
When installing, the installer will ask questions, you can use the default value directly to press the carriage return.
Here to remember to specify the INCLUDE and LIB location you just installed. Since there are still SASLs on a lot of Linux releases, if not specified, different versions of header files and libraries are likely to use, in which case SMTPD will fatally errors each time it is connected. "Fatal: SASL PER-Connection Server Init ..." crashes.
Modify the alias database location:
[root @ mail postfix-2.0.7] # CD / ETC
[root @mail etc] # mv aliases aliases.orig
[root @mail etc] # ln -s postfix / aliases aliases
Make a system alias for Postfix users and forward superuser mailboxes to a normal user such as Tester. Use the / etc / postfix / aliases alias database:
[root @mail etc] # cd postfix
[root @mail postfix] # echo 'root: Tester' >> / etc / postfix / aliases
Generate / etc / postfix / aliases alias database:
[root @mail postfix] # Postalias / etc / postfix / aliases
7.3. Configuration
Modify /etc/postfix/master.cf About Cyrus configuration, (Cyrus's command line and where you are not compatible, make sure your Cyrus parameters use -r $ {sender} parameters): [ Root @mail postfix] # vi master.cf
Will be as follows:
CYRUS UNIX - N N - PIPE
= cyrus argv = / cyrus / bin / deliver -e -r $ {sender} -m $ {extension} $ {user}
Modifications to:
CYRUS UNIX - N N - PIPE
= cyrus argv = / usr / cyrus / bin / deliver -e -r $ {sender} -m $ {extension} $ {user}
Here you must modify the path of Cyrus to your Cyrus actual installation path (we will install Cyrus-IMAP to / usr / cyrus below). Remember User = ... The front is indent in space.
[root @mail postfix] # vi main.cf
Modify /etc/postfix/main.cf configuration:
myhostname = mail.cngnu.org
Mydomain = cngnu.org
Myorigin = $ mydomain
MyDestination = $ MyDomain, $ MyHostName
Alias_maps = Hash: / etc / postfix / aliases
Alias_Database = Hash: / etc / postfix / aliases
Home_mailbox = maildir /
Mailbox_Transport = cyrus
Fallback_Transport = Cyrus
Virtual_maps = hash: / etc / postfix / virtual, mysql: /etc/postfix/mysql-virtual.cf
SMTPD_SASL_AUTH_ENABLE = YES
SMTPD_RECIPIENT_RESTRICTIONS = permit_sasl_authenticated permit_auth_destination reject
Broken_SASL_AUTH_CLIENTS = YES
SMTPD_SASL_SECURITY_OPTIONS = Noanonymous
SASL is used in the above profile to perform SMTP letter authentication. There is no SMTPD_SASL_LOCAL_DOMAIN parameter to specify a local authentication domain. If specified, it should be noted that the UserName field in the above database is to include this local domain: Tester@cngnu.org.
Create /etc/postfix/mysql-virtual.cf, which provides local users and email forwarding features. The FORWARD field and the username field value are the same by default. At this time, the message is submitted to the user mailbox: username@mydomain.com; Forward is another email address or user, the message forwarded to the new address. In addition, because postfix is case sensitive to mailbox, you can guarantee that the email address of the case can be properly received by the Virtual function.
[root @mail postfix] # vi mysql-virtual.cf
#
# MySQL Config File for Alias Lookups on Postfix
#
# The user name and password to log into the mysql serverhosts = localhost
User = mail
Password = secret
# The database name on the server
DBNAME = MAIL
# The Table Name
Table = User
SELECT_FIELD = Forward
Where_field = username
Additional_Conditions = and status = '1' Limit 1
Create the DB library of / etc / postfix / virtual above:
[root @mail postfix] # Postmap Virtual
The Virtual library that retains the DB format is for the system to add some virtual domains and forwarded.
7.4. Run
The start command is as follows:
[root @mail postfix] # / usr / sbin / postfix start
7.5. Test Postfix
After starting Postfix, first check the log / var / log / messages, there is no error message, then check the process, there should be the following process: check the port and process:
[root @mail postfix] # pstree | grep master
| -Master - - Pickup
Then check the port, there should be the following ports to open:
[root @mail postfix] # netstat -an | grep listen
TCP 0.0.0.0:250.0.0.0:0:0:0.0:0:0.0.0:0:0.0:0:0:0.0:0:0.0.0:0:1Listen
No SMTP service is normal:
[root @mail postfix] # telnet localhost 25
Trying 127.0.0.1 ...
Connected to Localhost.
Escape Character is '^]'.
220 mail.cngnu.org ESMTP Postfix
Quit
221 BYE
Connection Closed by Foreign Host.
Use the following command to test the POSTFIX's SMTP authentication:
PLAIN authentication method:
[root @mail postfix] # printf 'tester / 0000tester / 0000testpw' | MMencode
DGVZDGVYAHRLC3RLCGB0ZXN0CHC =
[root @mail postfix] # telnet localhost 25
Trying 127.0.0.1 ...
Connected to Localhost.
Escape Character is '^]'.
220 mail.cngnu.org ESMTP Postfix
EHLO CNGNU
250-mail00.cngnu.org
250-Pipelining
250-Size 10240000
250-VRFY
250-ETRN
250-auth login plain
250-auth = login plain
250-xverp
250 8bitmime
Auth Plain DGVZDGVYAHRLC3RLCGB0ZXN0CHC =
235 Authentication Successful
Quit
221 BYE
Connection Closed by Foreign Host.
Login authentication method:
[root @mail postfix] # printf 'tester' | MMENCodedGvzdgvy
[root @mail postfix] #printf 'testpw' | mmencode
DGVZDHB3
[root @mail postfix] # telnet localhost 25
Trying 127.0.0.1 ...
Connected to Localhost.
Escape Character is '^]'.
220 mail.cngnu.org ESMTP Postfix
EHLO CNGNU
250-mail.cngnu.org
250-Pipelining
250-Size 10240000
250-VRFY
250-ETRN
250-auth login plain
250-auth = login plain
250-xverp
250 8bitmime
Auth login
334 vxnlcm5hbwu6
DGVZDGVY
334 UGFZC3DVCMQ6
DGVZDHB3
235 Authentication Successful
Quit
221 BYE
Connection Closed by Foreign Host.
At this time, since Cyrus-IMAP has not been installed and created a mailbox, you can't submit the message, please continue the next step.
This uses MMencode to get the MIME-BASE64 encoded verification string. MMencode can be found in Metamail this package. In addition, you can also use the MIME :: Base64 module (need to be installed) in Perl: perl -mmime :: base64 -e 'print base64_encode ("Tester / 0Tester / 0TestPW");'.
8. Install Cyrus-IMAP
8.1. Download
http://asg.web.cmu.edu/cyrus/download/
[root @mail postfix] # CD / usr / src
[root @mail src] # wget
ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-imapd-2.1.12.tar.gz
8.2. Compilation and installation
Compile CYRUS-IMAP and cancel Kerberos support (in redhat, the Kerberos library has problems, it is difficult to compile, Mandrake can pass; in addition, we don't need Kerberos support) and SNMP support:
[root @mail src] # tar -zxf cyrus-imapd-2.1.12.tar.gz
[root @mail src] # cd cyrus-imapd-2.1.12
[root @ Mail cyrus-imapd-2.1.12] # ./configure --with-cyrus-prefix = / usr / cyrus /
> --with-sasl = / usr / local / lib / sasl2 --with-auth = UNIX /
> --without-ucdsnmp
[root @ mail cyrus-imapd-2.1.12] # make depend
[root @ mail cyrus-imapd-2.1.12] # make all cflags = -O
[root @ mail cyrus-imapd-2.1.12] # make install
If you are compiled, you have not found com_err.h, please copy the COM_ERR.H to / usr / include: [root @ mail cyrus-imapd-2.1.12] # cp et / com_err.h / USR / Include
\
[root @ mail cyrus-imapd-2.1.12] # cd Perl / IMAP
[root @ mail imap] # perl makefile.pl
[root @ Mail IMAP] # make install
8.3. Configuration
Create a master profile /etc/cyrus.conf:
[root @ Mail IMAP] # cd ../ ..
[root @ mail cyrus-imapd-2.1.12] # cp master / conf / small.conf /etc/cyrus.conf
Add CYRUS-IMAP management account CRYUS, which does not need to set your password, usually not logged in:
[root @ mail cyrus-imapd-2.1.12] # UserAdd -g mail -m -ss / no / shell cyrus
Create an IMAP profile /etc/imapd.conf, the administrator is Cyrus:
[root @ mail cyrus-imapd-2.1.12] # vi /etc/imapd.conf
ConfigDirectory: / VAR / IMAP
Partition-default: / var / spool / iMap
Admins: Cyrus
SASL_PWCHECK_METHOD: SASLAUTHD
About iMapd.conf can refer to the Cyrus-IMAP documentation to configure other available parameters.
Since the Cyrus-IMAP management program CYRADM and its modules are found in / etc / sasldb2 in / etc / sasldb2 when the authentication management user is authenticated, the file is required:
[root @ mail cyrus-imapd-2.1.12] # SASLPasswd2 -c Cyrus
Password: Cyrus
Again (for verification): Cyrus
[root @ Mail cyrus-imapd-2.1.12] # chown -r cyrus / etc / sasldb2
Establish a directory structure of a Cyrus-IMAP server:
[root @ mail cyrus-imapd-2.1.12] # mkdir -p / var / IMAP / SIEVE
[root @ mail cyrus-imapd-2.1.12] # mkdir / var / spool / IMAP
[root @ mail cyrus-imapd-2.1.12] # chown -r cyrus: mail / var / iMap
[root @ mail cyrus-imapd-2.1.12] # chown -r cyrus: mail / var / spool / iMap
[root @ mail cyrus-imapd-2.1.12] # su -s / bin / bash cyrus
BASH-2.05 $ TOOLS / MKIMAP
BASH-2.05 $ EXIT
This tools / mkimap this utility inside the source of Cyrus-IMAP.
Create a log:
[root @mail cyrus-imapd-2.1.12] # echo local6.debug /var/log/imapd.log >> /etc/syslog.conf[Root@mail cyrus-imapd-2.1.12] # echo auth.debug /VAR/LOG/AUTH.LOG >> /ETC/SYSLOG.CONF
[root @ Mail cyrus-imapd-2.1.12] # /etc/rc.d/init.d/syslog restart
Setting the email limit:
[root @ mail cyrus-imapd-2.1.12] # chattr -r s / var / iMAP / User
[root @ mail cyrus-imapd-2.1.12] # chattr -r s / var / omap / quota
[root @ mail cyrus-imapd-2.1.12] # chattr -r s / var / spool / IMAP
Since the Cyrus-IMAP's master process and Postfix's master process name, it is easy to confuse and it is inconvenient to control, so the main control process of the Cyrus-IMAP server is used to connect: Cyrusd.
[root @ mail cyrus-imapd-2.1.12] # CD / usr / cyrus / bin
[root @ mail bin] # ln - master cyrusd
8.4. Run
The start command is as follows:
[root @mail bin] # / usr / cyrus / bin / cyrusd &
8.5. Test Cyrus-IMAP
After starting CYRUS-IMAP, first check the log /var/log/messages ,/var/log/Auth.log and /var/log/auth.log There is no error message, then check the process, there should be the following process:
[root @ mail bin] # pstree | grep cyrusd
| -cyrusd
Then check the port, there should be the following ports to open:
[root @ mail bin] # Netstat -an | GREP LISTEN
TCP 0.0.0.0:0.0:0:0.0:0:0:0:0.0:0.0:0:0:0.0.0:0:1Listen
TCP 0.0.0.0:0.0:0:0:0:0:0:0:0:0:0:0:0.0:0:0:0.0:0:0.0:0:0.0:0:0:1Listen
now create an email.
Use Cyradm to create and delete the mailbox, which is the interactive management interface of Cyrus-IMAP yourself. The current version is written with Perl. You can also call the Cyrus :: iMap :: admin module directly to create your own CGI or script to do mailbox management, you can refer to the program of the Cyrus :: IMAP :: Shell module.
[root @mail bin] # cyradm --user cyrus localhost
IMAP Password:
Mail.cngnu.org> cm user.cyrus
Mail.cngnu.org> SQ User.cyrus Storage 10240000
Mail.cngnu.org> cm user.tester
mail.cngnu.org> SQ User.Tester Storage 10240000
Mail.cngnu.org> LM
User.cyrus
Mail.cngnu.org> quit
If you want to delete an IMAP mailbox, you need to grant the administrator Cyrus to C (create) and d (delete) permission can be deleted.
[root @mail bin] # cyradm --user cyrus localhostimap password:
Mail.cngnu.org> CM User.TestDel
Mail.cngnu.org> LM
User.cyrus t t t t t t t t t t t
Mail.cngnu.org> SAM User.testdel Cyrus CD
Mail.cngnu.org> DM User.testdel
Mail.cngnu.org> LM
User.cyrus
Mail.cngnu.org> quit
Repeat POP3 and IMAP services:
[root @ mail bin] # Telnet localhost 110
OK mail.cngnu.org cyrus pop3 v2.1.12 server ready
User Tester
OK Name is a Valid Mailbox
Pass testpw
OK MAILDROP LOCKED and Ready
Quit
OK
[root @ mail bin] # tetest -m login -a tester localhost
C: C01 Capability
S: * ok mail.cngnu.org cyrus imap4 v2.1.12 Server Ready
S: * Capability Imap4 Imap4REV1 ACL Quota Literal Namespace Uidplus ID NO_AMIC_RENAME Unselect Multiappend Sort thread = OrderedSubject thread = References idle
S: C01 OK Completed
PASSWORD:
C: l01 login tester {6}
Go Ahead
C:
L01 OK User Logged in
Authenticated.
Security Stregity Factor: 0
Logout
* BYE LOGOUT RECEIVED
Ok Completed
9. Install IMP
9.1. Download
http://www.php.net/get_download.php?df=php-4.3.1.tar.gz
http://www.horde.org/horde/
http://www.horde.org/imp/3.2.1/
http://www.horde.org/turba/
[root @ mail bin] # CD / USR / SRC
[root @mail src] # wget
http://www.php.net/distributions/php-4.3.1.tar.gz
[root @mail src] # wget
ftp://ftp.horde.org/pub/horte/horde-2.2.1.tar.gz
[root @mail src] # wget
ftp://ftp.horde.org/pub/pear/pear-1.0.1.tar.gz
[root @mail src] # wget
ftp://ftp.horde.org/pub/imp/imp-3.2.1.tar.gz
[root @mail src] # wget
ftp://ftp.horde.org/pub/turba/turba-1.2.tar.gz
9.2. Configuring Apache and PHP
IMP is high for PHP environment. So usually need to upgrade the PHP package and install the PEAR package customized by Horde. Before compiling a new PHP package, please confirm that there is Apache (here you use Apache 2) and other related packages. Reed HTTPD-DEVEL Pack No Apache 2 is used to install the script of the DSO module: INSTDSO.SH, please get from the Apache 2.x release package and put into / usr / lib / httpd / build.
[root @mail src] # TAR ZXF PHP-4.3.1.tar.gz
[root @mail src] # CD PHP-4.3.1
[root @ Mail PHP-4.3.1] # ./configure --prefix = / usr --with-config-file-path = / etc /
> --with-mysql --with-apxs2 /
> --Nable-ftp --enable-magic_quotes --With-XML /
> --with-getText --with-IMAP /
> --with-imap-ssl --with-kerberos = / usr / kerberos
[root @ Mail PHP-4.3.1] # Make
[root @ Mail PHP-4.3.1] # make install
[root @ Mail PHP-4.3.1] # [-f /etc/php.ini] && mv /etc/php.ini /etc/php.ini.orig
[root @ Mail PHP-4.3.1] # cp php.ini-dist /etc/php.ini
Modify /etc/php.ini and open the Register_Global function.
Register_globals = on
Install PEAR package:
[root @ Mail PHP-4.3.1] # CD / USR / LIB
[root @mail lib] # [-d php] && mv php php.orig
[root @mail lib] # tar zxf /usr/src/pear-1.0.1.tar.gz
[root @mail lib] # mv pear php
Finally restart Apache:
[root @mail lib] # /etc/rc.d/init.d/httpd restart
9.3. Configuring Horde
Install Horde:
[root @ mail lib] # cd / var / www / html
[root @mail html] # tar zxf /usr/src/horde-2.2.1.tar.gz
[root @mail html] # mv horde-2.2.1 Horde
[root @mail html] # CD HORDE / SCRIPTS / DB
[root @mail db] # mysql [root @mail db] # cd ../../config [root @mail config] # for foo in * .dist; do cp $ foo `basename $ foo .dist`; DONE Then modify the horde.php below the config directory. [root @mail config] # vi horde.php Modify 148 lines: $ conf ['prefs'] ['driver'] = 'none'; $ conf ['prefs'] ['driver'] = 'sql'; modify 157 lines to 162 lines, annotate the password of the Horde database: // $ conf ['prefs'] ['params'] ['phpoType'] = 'mysql'; // $ conf ['prefs'] ['params'] ['Hostspec'] = 'localhost'; // $ conf ['prefs'] ['params'] ['username'] = 'horde' // $ conf ['prefs'] ['params'] ['Password'] = '*****'; // $ conf ['prefs'] ['params'] ['Database'] = 'horde' // $ conf ['prefs'] ['params'] ['Table'] = 'horde_prefs' $ conf ['prefs'] ['params'] ['phpoType'] = 'mysql'; $ conf ['prefs'] ['params'] ['Hostspec'] = 'localhost'; $ conf ['prefs'] ['params'] ['username'] = 'horde' $ conf ['prefs'] ['params'] ['password'] = 'horde' $ conf ['prefs'] ['params'] ['Database'] = 'horde'; $ conf ['prefs'] ['params'] ['Table'] = 'horde_prefs'; Here we do not modify the default database settings for the Horde database. If in actual use, at least one complicated password should be taken. Let's modify the registry.php below the config directory. [root @mail config] # vi registry.php Modify 23 lines to 24 lines, remove it: // $ this-> registry ['auth'] ['login'] = 'IMP' // $ this-> registry ['auth'] ['logout'] = 'IMP' $ this-> registry ['auth'] ['login'] = 'IMP' $ this-> registry ['auth'] ['logout'] = 'IMP' Then modify 109, 118 rows to activate IMP and Turba: 'status' => 'inactive' 'status' => 'Active' Last in the browser to access whether the URL test HORDE needs to be satisfied: http: // Your IMP server IP / Horde / Test.php If you find a red tip, you may need to modify your PHP installation and configuration (see the previous section), then retest. 9.4. Configuring IMP Install IMP: [root @mail config] # cd .. [root @mail horde] # tar zxf /usr/src/imp-3.2.1.tar.gz [root @mail horde] # mv IMP-3.2.1 IMP [root @ mail horde] # CD IMP / Config [root @mail config] # for foo in * .dist; do cp $ foo `basename $ foo .dist`; DONE Then modify the conf.php in the config directory: [root @mail config] # vi conf.php Modify 37 lines: $ conf ['menu'] ['apps'] = array (); $ conf ['menu'] ['Apps'] = Array ('Turba'); Modify 57 lines: $ conf ['user'] ['allow_resume_all'] = false; $ conf ['user'] ['allow_resume_all'] = true; Modify 63 lines: $ conf ['user'] ['allow_resume_all_in_drafts'] = false; $ conf ['user'] ['allow_resume_all_in_drafts'] = TRUE; Then modify prefs.php: [root @mail config] # vi prefs.php The automatic maintenance function is turned off, modified 424, 425 lines: 'Value' => 1, 'locked' => false, 'Value' => 0, 'Locked' => True, Note 773 lines: 'Value' => '', // 'Value' => '', Cancel Notes 774 lines: // 'Value' => 'Localsql', 'Value' => 'Localsql', Finally modify servers.php: [root @mail config] # vi servers.php Note All server configurations outside the "Cyrus" server, then modify the configuration of the "Cyrus" server: $ Servers ['Cyrus'] = Array ( 'name' => 'cyrus imap server', 'Server' => 'localhost', 'Protocol' => 'IMAP / NOTLS', 'Port' => 143, 'allDers' => '', 'Namespace' => 'Inbox.', 'maildomain' => 'CNGNU.ORG', 'Realm' => 'CNGNU.ORG', 'preferred' => '' ' ); 9.5. Configuring Turba Install Turba: [root @mail config] # cd ../ .. [root @ mail horde] # tar zxf /usr/src/turba-1.2.tar.gz [root @mail horde] # mv Turba-1.2 Turba [root @ mail horde] # cd Turba / Config [root @mail config] # for foo in * .dist; do cp $ foo `basename $ foo .dist`; DONE Then modify the conf.php in the config directory: [root @mail config] # vi conf.php Modify 32 lines: $ conf ['menu'] ['apps'] = array (); $ conf ['menu'] ['Apps'] = Array ('IMP'); 9.6. Test IMP Last to the browser to access the following URL: http: // Your IMP server IP / Horde / Enter the username Tester and password TestPW login. 10. Others 10.1. Start the script You can write a startup script mailsys to launch these processes, so you don't need to start Postfix and CyrusD separately: #! / bin / bash # # mailsys this shell script takes Care of Starting and Stopping # Postfix and cyrus-iMap. # Author: xingyu.wang # # chkconfig: 2345 80 30 # Description: Postfix is a mail transport agent, Which is the program # That Moves Mail from One Machine to Another.Cyrus-IMAP IS A MAIL # Deliver Agent, Which Provide Pop3 and Imap4 Services for User and # Deliver Mail to Local Mailbox. # # processname: mailsys # pidfile: /var/run/mailsys.pid # Source Function Library. . /etc/rc.d/init.d/functions # Source NetWorking Configuration. . / etc / sysconfig / network # Check That Networking is up. [$ {Networking} = "no"] && exit 0 [-f / usr / sbin / postfix] || EXIT 0 [-f / usr / cyrus / bin / cyrusd] || EXIT 0 Retval = 0 PROG = "mail system" START () { # Start daemons. echo -n $ "Starting $ PROG:" Echo -n $ "SASL" / usr / local / sbin / saslauthd -a pam Echo -n $ "smtp" / usr / sbin / postfix start> / dev / null 2> & 1 Echo -n $ "POP3 IMAP4" / usr / cyrus / bin / cyrusd> / dev / null 2> & 1 RetVal = $? IF [$ RETVAL-EQ 0]; THEN Touch / Var / Lock / Subsys / Mailsys SUCCESS $ "$ prog start" Else Failure $ "$ PROG Start Failure" Fi echo Return $ RetVal } STOP () { # Stop daemons. echo -n $ "Shutting down $ PROG:" Echo -n $ "smtp" / usr / sbin / postfix stop> / dev / null 2> & 1 Echo -n $ "POP3 IMAP4" KillProc Cyrusd Echo -n $ "SASL" KillProc Saslauthd RetVal = $? IF [$ RETVAL-EQ 0]; THEN RM -F / VAR / LOCK / SUBSYS / MAILSYS SUCCESS $ "$ prog stop" Else Failure $ "$ prog stop failure" Fi echo Return $ RetVal } # See how wee wee caled. Case "$ 1" in START) Start ; STOP) STOP ; Restart | Reload) STOP Start RetVal = $? ; *) Echo $ "Usage: $ 0 {start | stop | restart}" EXIT 1 ESAC EXIT $ RETVAL [root @mail root] # chmod 755 /etc/rc.d/init.d/mailsys [root @mail root] # cd /etc/rc3.d [root @ mail rc3.d] # ln -s ../init.d/mailsys s80mailsysysys [root @mail rc3.d] # rm -rf s80sendmail 10.2. Overall test After creating an email address, the test message is: [root @mail root] # mail tester Subject: Test by ME THIS IS. . CC: [root @mail root] # mailq Mail Queue Is Empty [root @mail root] # tail / var / log / mail / * Use Mailq to see if the mail queue has an error, and checks / var / log / mail / * whether there is an error message. If everything is normal, the letters have been sent to Tester. Testing, first test POP3: [root @mail root] # Telnet localhost 110 OK mail.cngnu.org cyrus pop3 v2.1.12 server ready User Tester OK Name is a Valid Mailbox Pass testpw OK MAILDROP LOCKED and Ready List 1 400 TOP 1 10 Return-path: X-SIEVE: CMU-SIEVE 2.0 Return-path: Received: by Mail. (Postfix, from userid 0) ID 5F1EF90005; MON, 20 May 2002 18:03:43 0800 (CST) TO: Tester@cngnu.org Subject: Test by ME Message-id: <20020520100343.5f1ef90005@mail00.cngnu.org> Date: Mon, 20 May 2002 18:03:43 0800 (CST) From: root@cngnu.org (root) THIS IS. . Quit OK Test IMAP again: [root @mail root] # tetest -m login -a tester localhost C: C01 Capability S: * ok mail.cngnu.org cyrus imap4 v2.1.12 Server Ready S: * Capability Imap4 Imap4REV1 ACL Quota Literal Namespace Uidplus ID NO_AMIC_RENAME Unselect Multiappend Sort thread = OrderedSubject thread = References idle S: C01 OK Completed PASSWORD: C: l01 login tester {6} Go Ahead C: L01 OK User Logged in Authenticated. Security Stregity Factor: 0 SELECT INBOX * Flags (/ answer / flagged / Draft / deleted / seen) * OK [permanentflags (/ answer / flagged / Draft / deleted / see / *)] * 1 EXISTS * 1 Recent * OK [UidValidity 1021736432] * OK [UidNext 3] . Ok [read-write] completed Fetch 1: 1 (Flags Body [Header.fields (Date from)]) * 1 fetch (Flags (/ seen) body [header.fields (date from)] {68} Date: Mon, 20 May 2002 09:26:09 0800 (CST) From: wxy@cngnu.org ) Ok Completed Logout * BYE LOGOUT RECEIVED OK Completed Final Test IMP, visit the following URL in the browser: http: // Your IMP server IP / Horde / Enter the username Tester and password TestPW login. You can also use any other mail client programs to test, such as Kmail, Outlook Express, etc.