Create a fully functional email system

Source: Internet
Author: User
Tags imap mx record

This system can be called a full function: it can implement almost all the functions supported by a popular mail system, this includes sending attachments, POP3 or IMAP email receiving methods, user folder management, address book, and password modification. If you want to, you can also implement calendar, notepad, and other functions. All these functions can be implemented through web, that is, webmail.
[Directory]
I. Basic principles of the Mail System
2. Required Network Environment
3. Install the Operating System
4. Install sendmail
5. Install IMAP
6. Install Web mail support-Apache, MySQL, and PHP
7. Install Web mail
8. Install the address book Module
9. Install and change the password Module

I. Basic principles of the Mail System
First, let's take a look at the basic principles of the email system. Here is a brief introduction. For more information, see related books.
Generally, the email program is divided into user agents, transmission agents, and delivery agents. The user proxy transfers users' emails to the transmission proxy (such as Outlook Express and Foxmail ). The mail Transmission proxy is responsible for sending emails to the target host (such as Sendmail ). The shipping agent obtains the mail from the mail transmission agent and sends it to the end user's mailbox (such as procmail ).
We can simulate the process from sending to receiving an email. You can use Outlook Express (user agent or mail client) to send an email request to Sendmail (transport agent) and send the email to Sendmail. Sendmail sends an email to the receiving server based on the target address of the email, and the receiving Server caches the email (this is also the work of Sendmail ). The recipient sends a receiving request to the receiving server using Outlook Express. The receiving server sends the email to the user (this is the work of the IMAP or POP service ). At this point, an email is sent from the sender's machine to the recipient's machine.
We want to build a mail server with a RedHat Linux 7.3 operating system with superior performance. Sendmail is used as the mail Transmission Service, and IMAP is used as the mail receiving service to form the basic framework of the mail system. Use horde imp as the mail Web Client. The rest is the support software of horde imp: user data is stored in MySQL, and Apache + PHP is used as the web server. We also use other modules to expand the functions of the system: Address Book module and password modification module.
We will install the following software:

1. RedHat linux7.3
Role: Operating System
: Http://freesoft.online.sh.cn: 8888/mirrors/RedHat/7.3/

2. Sendmail-8.11.6
Role: Mail transmission and receipt
:( RedHat 7.3)
3. imap
Role: IMAP and POP3 servers
: Ftp://ftp.cac.washington.edu/imap/imap-2001a.tar.Z

4. APACHE-1.3.24
Role: Web Server
: Http://freesoft.online.sh.cn: 8888/mirrors/ftp.apache.org/httpd/apache_1.3.24.tar.gz

5. PHP-4.2.1
Role: CGI script language
: Http://www.php.net/do_download.php? Download_file1_php-4.2.1.tar.gz

6. Pear-4.1.0
Role: function extension module of PHP
: Ftp://ftp.horde.org/pub/horde/tarballs/pear-4.1.0.tar.gz

7. MySql
Role: database, storing Mail User Data and address book
: Http://freesoft.online.sh.cn: 8888/mirrors/Database/MySQL/mysql-3.23.49.tar.gz

8. Hordes-2.1
Role: Imp Support Module
: Ftp://ftp.horde.org/pub/horde/tarballs/horde-2.1.tar.gz
Patch: ftp://ftp.horde.org/pub/horde/tarballs/patch-horde-2.0-2.1.gz

9. Imp-3.1
Role: core program of Web mail
: Ftp://ftp.horde.org/pub/imp/tarballs/imp-3.1.tar.gz
Patch: ftp://ftp.horde.org/pub/imp/tarballs/patch-imp-3.0-3.1.gz

Turba-1.1
Function: Provides the address book function.
: Ftp://ftp.horde.org/pub/turba/tarballs/turba-1.1.tar.gz
Patch: ftp://ftp.horde.org/pub/turba/tarballs/patch-turba-1.0-1.1.gz

11. Poppassd-1.8.2
Role: the password change service, combined with Passwd for imp, provides the Web-based user password modification function.
: Http://echelon.pl/pubs/poppassd-1.8.2.tar.gz

12. passwd for IMP
Role: provides the password change function module
: Https://mail.ph.utexas.edu/test2/patches/public/passwd/passwd.tgz

2. Required Network Environment
This document assumes that you want to set up an email server in the campus network to provide email services for the users of this Organization. The server has a valid IP address 202.99.11.200 and a valid domain name mail.example.com, And the dns mx record of example.com directs to mail.example.com.
Note: To meet domain name requirements, the domain data file of example.com DNS should contain the following content:
In MX 10 mail
Mail in a 202.99.11.200

3. Install the operating system RedHat linux7.3
RedHat linux7.3 has been installed in many documents for detailed instructions. Here we will only talk about the partition problem. As a mail system, the main disk space is used to store users' emails. Most of the software is installed in/usr, and emails received by users are stored in/var. emails processed by users (such as deletion and mobile devices) are stored in/home. You should determine a reasonable Partition Scheme Based on your own situation.

4. Install sendmail
In fact, after RedHat linux7.3 is installed, Sendmail is installed. If not, use the RPM package on the first installation disk of RedHat linux7.3. Next we will only make some simple settings for Sendmail.
The configuration file for Sendmail is/etc/sendmail. cf. Here, we need to modify two places:
Original content: Cwlocalhost (about 83 rows)
Change to: Cwexample.com
Purpose: Define the email exchange domain
Original content: O deamonPortoptions = Port = smtp, Addr = 127.0.0.1... (About 260 rows)
Modify to: (comment out this line)
Purpose: This line only allows the use of the smtp service from the local machine, as a mail system, which obviously does not work.
After the modification is complete, type:
#/Etc/rc. d/init. d/sendmail restart
Restart sendmail to make the modification take effect.

5. Install IMAP
IMAP provides IMAP and POP3 services. They provide interfaces for receiving mails. Here we only use the IMAP service.
Assume that all the software to be installed has been downloaded to/tmp. All commands involved in this article are executed as root.
1. Unzip and install:
# Cd/tmp
# Tar zxvf imap-2001a.tar.Z
# Cd imap-2001a
# Make slx

2. Copy the generated executable file to/usr/sbin.
# Cp imapd/usr/sbin

3. Create an imap file under/ect/xinetd. d.
# Vi/etc/xinetd. d/imap
Content:
# IMAP server at Port 143
Service imap
{
Disable = no
Socket_type = stream
Wait = no
User = root
Server =/usr/sbin/imapd
}

4. Restart xinetd
/Ect/rc. d/init. d/xinetd restart

5. Test the imap service.
# Telnet to localhost 143
If you see the welcome information, the IMAP server is successfully installed. Note: Do not delete the Installation File of IMAP, which will be used later.

6. Install Web mail support-Apache, Mysql, and PHP
In this step, we need to establish Web server and database support for Imp.
1. Install MySql
Web mail Imp stores user settings and address book in the database. We use MySql.

1.1 decompress and configure compilation and installation:
# Cd/tmp
# Tar zxvf mysql-3.23.47.tar.gz
# Cd mysql-3.23.47
#./Configure -- prefix =/usr/local/mysql
# Make
# Make install
After installation, MySql is installed in/usr/local/mysql.

1.2 create a mysql user and a mysql Group
# Groupadd mysql
# Useradd mysql
# Passwd mysql

1.3 start MySql:
# Cd/usr/local/mysql/bin
#./Mysql_install_db (install the basic MySql database)
#./Safe_mysqld-uroot & (start MySql and transfer it to the background)
1.4 test MySql

#./Mysql
If you can connect to the database, MySql installation is complete. Change the root password of MySql to increase security. For more information, see.

2. install Apache, PHP, and PEAR
Horde and Imp are written in PHP. To make them run, you must provide Web Services and PHP script language support. PEAR is a function extension module of PHP, although PEAR has been installed in PHP by default, Horde requires a newer version.

2.1 unzip:
# Cd/tmp
# Tar zxvf apache-1.3.24.tar.gz
# Tar zxvf php-4.2.1.tar.gz
2.2 pre-compile Apache
# Cd for apache-1.3.24
#./Configure

2.3 configure, compile, and install PHP. Add relevant parameters according to imp's needs. You can modify the parameters according to relevant information.
# Cd ../php-4.2.1
#. /Configure -- with-mysql =/usr/local/mysql -- with-apache = .. /apache-1.3.24 -- with-imap = .. /imap2001a -- with-gettext -- with-xml
# Make
# Make install

2.4 configure, compile, and install Apache
# Cd ../apache-1.3.24
#./Configure -- prefix =/usr/local/apache -- activate-module = src/modules/php4/libphp4.a

2.5 copy the PHP configuration file to/usr/local/lib
# Cd ../php-4.2.1
# Cp php. ini-recommended/usr/local/lib

2.6 replace the old PEAR version with the new version
# Cd/usr/local/lib
# Mv php. bak
# Cp/tmp/pear-4.1.0.tar.gz.
# Tar zxvf pear-4.1.0.tar.gz
# Mv pear-4.1.0 php
# Chown root. root-R php

2.7 modify the Apaceh configuration file/usr/local/apache/conf/http. conf for PHP
Find the following two rows:
# AddType application/x-httpd-php. php
# Addtype application/X-httpd-PHP-source. PHPs
Remove the annotator to define the suffix of the PHP document.
You also need to modify the default homepage type and find:
Directoryindex index.htm
Changed:
Directoryindex index.htm index. php default.htm default. php

2.8 start Apache
#/Usr/local/Apache/bin/apachectl start

2.9 test Apache and PHP
Delete all files under/usr/local/Apache/htdocs/
# Cd/usr/local/Apache/htdocs/
# Rm-RF *
Create a file named test. php with the following content:

Find a machine that can access the Internet and enter http://mail.example.com/test.php in the address bar of the browser. If you can see the PHP related information, it indicates that apacheand PHP are successfully installed.

7. Install Web mail
IMP is http://horde.org/logs. It is a mail client program with a fully functional web interface written in PHP. It uses the IMAP or POP3 protocol to connect to the mail server and complete various functions of the mail system. It also supports multiple language interfaces, including simplified Chinese.
Horde is the Horde Application Framework (Application Framework) of http://horde.org/example. All Programs in http://horde.org/must be based on horde, and impis is not an example. First, install horde.

1. Install Horde
1.1 copy the Horde compressed package to the root directory of the web server and decompress it.
# Cd/usr/local/Apache/htdocs
# Cp/tmp/horde-2.1.tar.gz.
# Tar zxvf horde-2.1.tar.gz
# Mv horde-2.1 Horde

Application patch:
# Cd Horde
# Cp/tmp/patch-horde-2.0-2.1.gz.
# Gunzip patch-horde-2.0-2.1.gz
# Patch-P1 1.2 prepare databases for horde and IMP
Make sure that MySQL is running. We will create the databases required for horde and IMP in MySQL. You can use an SQL script file in horde to automatically complete this task. Before performing this operation, you must modify the password of the database user.
# Cd horde/scripts/DB
# Vi mysql_create. SQL
Find the following content:
Replace into user (host, user, password)
Values (
'Localhost ',
'Horde ',
-- Important: change this password!
Password ('horde') // User Password
);
Change the Italic content to your own password. Here we assume that it is changed to "XXX ".
Create a database:
#/Usr/local/mysql/bin/mysql <mysql_create. SQL
Note: If you have set a password for the root user of Mysql, you must provide the password in the above command.
If yes, a database named horde is created in MySql. The database owner is horde and the password is "xxx ".
Run the following command to test whether the database is successfully created:
# Mysql-h localhost-u horde-pxxx
Mysql> exit

1.3 set Horde
The settings of Horde and Imp are stored in their configuration files.
Copy the configuration file:
# Cd horde/config
# For foo in *. dist; do cp-v $ foo 'basename $ foo. dist'; done
Edit the following files:
1.3.1 Horde setting file horde. php
// Use IMAP as logon authentication
$ Conf ['auth'] ['driver '] = 'imap ';
$ Conf ['auth'] ['params'] = array ();
$ Conf ['auth'] ['params '] ['dsn'] = '{localhost/imap: 143} inbox ';

// Use MySql to store user data
$ Conf ['prefs'] ['driver '] =' SQL ';
$ Conf ['prefs'] ['params'] = array ();
$ Conf ['prefs'] ['params'] ['phptype '] = 'mysql ';
$ Conf ['prefs'] ['params'] ['hostspec '] = 'localhost'; // Database Server
$ Conf ['prefs'] ['params'] ['username'] = 'horde'; // Database User
$ Conf ['prefs'] ['params '] ['Password'] = 'xxx'; // password set during database creation
$ Conf ['prefs'] ['params'] ['database'] = 'horde'; // database
$ Conf ['prefs'] ['params'] ['table'] = 'horde _ prefs'; // table

// Use Sendmail to send an email
$ Conf ['mailer'] ['type'] = 'sendmail ';

1.3.2 language setting file lang. php
$ Nls ['defaults'] ['language'] = 'zh _ cn'; // set the default language to simplified Chinese

(End)

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.