Getting started with Linux networking (3): E-Mail Server

Source: Internet
Author: User
Tags mail account microsoft iis microsoft outlook
Article Title: Linux networking entry (3): E-Mail server. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
  
Before the emergence of the WWW Service on the Internet, the email system was once the most widely used application service. Email brings convenience to people's communication. in the twinkling of an eye, various blessings and messages are sent over the Internet. It makes communication easier.
  
6.1 working principle of the email system
The operation of the email system is fundamentally different from that of other network applications. In most other network applications, network protocols directly send data to the destination. In the email system, the sender does not wait for the sending to complete, but only sends the content to be sent.
For example, the file transfer protocol (FTP) is like making a phone call to connect both parties in real time. If one party does not yet respond, the call will fail. The email system is different. The sender will send the mail to the recipient's email Post Office through his own email. If the recipient's email Post Office is currently busy, the sender's email Post Office will save the mail until it can be sent. When the recipient does not access the Internet, the recipient's email post office saves the mails until the recipient retrieves them. In this case, the email system implements the traditional post office function on the Internet, and is more convenient and convenient.
To connect to the Internet as a common user, you must contact an Internet Service Provider (ISP) to provide the Connection Service. In China, China Telecom is the largest ISP. While providing connections, the ISP also provides an electronic post office and assigns an electronic mailbox to users. There are also many free email Post Offices on the Internet to provide email services.
It is worth mentioning that an email always has a space description. What does this mean? That is, the space for saving mails provided by the e-Post Office to each user. Of course, the bigger the better.
  
6.2 email Standard
The protocol standard for email is part of the TCP/IP protocol family. It specifies the email format and protocol for email exchange between post offices.
Each email is divided into two parts: the mail header and the mail content. TCP/IP specifies the format of the email header, and allows you to customize the format of the email content. The two most important parts in the mail header are the email addresses of the sender and receiver. The email address format is as follows:
Username @ email Post Office domain name example: abc@990.net
The email transmission protocols (that is, the email exchange protocol between post offices) mainly include SMTP (Simple Mail transmission protocol), POP (email Post Office Protocol ), and the emerging IMAP (Internet Mail Application Protocol ).
  
6.3 composition of the email system
The entire email application system consists of two parts:
1. Electronic Post Office System;
2. Email sending and receiving system.
Email sending and receiving systems are like mailboxes in thousands of households. senders and recipients send and receive emails from and from their computers. This part is a client program running on a computer. The most common applications include Microsoft Outlook Express, Netscape, The Bat, Foxmail, and founder Feifei. You can select different programs based on your preferences. Basically, they implement the same functions.
The e-Post Office functions like a traditional post office. It serves as a bridge between the sender and receiver. It is a server-side program running on the e-Post Office Server. Microsoft IIS and sendmail are commonly used. Here we will introduce the most basic configuration and usage of the powerful and free email server program sendmail Based on UNIX-like operating systems.
  
6.4 install sendmail
If you select the E-MAIL service when installing LINUX, sendmail is already installed in LINUX and has made some basic settings.
If you have no choice during installation, or you need to upgrade sendmail, you can use the following methods.
1. install or upgrade using the RPM package (only for RedHat LINUX ):
1) First, find the following RPM packages on the CD or on the Internet:
Sendmail-8.9.3-10.i386.rpm sendmail executable
Sendmail-cf-8.9.3-10.i386.rpm sendmail. cf Builder
Sendmail-doc-8.9.3-10.i386.rpm sendmail. cf documentation
2) run the following command to install or upgrade:
Install: rpm? Ivh sendmail-8.9.3-10.i386.rpm
Upgrade: rpm? Uvh sendmail-8.9.3-10.i386.rpm
2. Use source code compilation to close installation:
1) first get the latest version of the source code: http://www.sendmail.org/
Ftp://ftp.dlut.edu.cn/pub/unix/mail/sendmail/
2) Expand the source code:
Cd/hometar? Zxvf sendmail-8.9.3.tar.gz
This will create a sendmail-8.9.3 directory under the/home directory:
/Home/sendmail-8.9.3/README
/Home/sendmail-8.9.3/src
/Home/sendmail-8.9.3/cf
/Home/sendmail-8.9.3/doc
3) Compile: Because sendmail has a Build program, the make command is not required:
CDS/home/sendmail-8.9.3/src
./Build
Install
  
6.5 use sendmail to build an e-mail server
After installing sendmail in the system, we can use this machine to become our e-Post Office. Because sendmail is powerful and tedious to configure. Therefore, the following section describes how to set up an Internet E-Mail server for a company.
The following settings can also be used in large e-Post Office applications. However, as the number of users increases, the performance of the whole post office may decline, in this case, more in-depth configuration work is required. Considering that this book is an entry-level reader, we will not discuss it in depth. Interested readers can refer to relevant books.
All in all, I hope that after the description in this chapter, you can use LINUX to build a small and practical e-Post Office quickly. Let's get started!
  
6.5.1 set sendmail to start as a daemon process
If you select the e-mail service when installing LINUX. Then, sendmail is started as a guard process. The so-called guard process refers to it, just like the resident memory program in the DOS operating system. After running, they listen in the background. When it is needed for service, it completes specific functions and services. In LINUX, many services are started in the form of process guard.
You can run the following command to check whether sendmail has been started.
Ps? A | grep sendmail
If sendmail is started, this command displays its related information. Otherwise, return to the command line without any prompt. If it is not started, you can add the following lines of code to the/etc/rc. d/rc.net file.
If [-f/usr/lib/sendmail];
Then (cd/usr/spool/mqueue; rm? F if *)
/Usr/lib/sendmail-bd-qlh; echo? N 'sendmail'>/dev/console
Fi
  
6.5.2 set sendmail. cf
Sendmail. cf is the configuration file of sendmail. Generally, after the LINUX system is installed, it will automatically generate a sendmail suitable for the system. cf file, and there are many sendmail adapted to various systems under the sendmail.8.9.3/cf directory. cf file samples can be used to determine the applicable scenarios based on the file name. You can choose to replace the original sendmail. cf file. That is, copy them to the/etc directory to overwrite the original sendmail. cf file.
Sendmail also provides the sendmail. cf generator m4, which generates a custom sendmail. cf file through a series of man-machine conversations. For more information, see the m4 help document. We will not detail it here.
  
6.5.3 enable SMTP and POP ports
In the Internet, we use the POP port to provide the mail receiving service and the SMTP port to provide the mail sending service. That is to say, the client's mail sending and receiving system connects to the SMTP port of the e-Post Office when sending the mail; when receiving the mail, connect to the POP port of the Electronic Post Office.
Generally, in all UNIX-like systems, SMTP ports are opened by default, while POP ports are closed by default.
1. Use root (super permission) to log on to the server;
2. Edit the/etc/inetd. conf file;
3. Find the statement describing the POP port;
# Pop2 stream tcp nowait root/usr/sbin/tcpd/usr/sbin/in. pop2d
# Pop3 stream tcp nowait root/usr/sbin/tcpd/usr/sbin/in. pop3d
The preceding # indicates that this line is a comment statement and does not take effect.
POP2 is an earlier version of the port protocol. Currently, we generally use POP3.
4. Remove the comment "#" of the POP3 description statement line. Make sure that the line in POP2 is a comment statement.
5. If not found, manually add this line. (In addition, we can also verify whether there is a description statement for the SMTP port );
6. Save the disk and exit.
7. Run the inetd command to make the settings take effect.
8. Run the following command to check whether the POP3 port is enabled (effective ).
Netstat? A | grep pop
If it is enabled, you can see the following information:
Tcp 0 0 *: pop3 *: * LISTEN
  
6.5.4 open an e-mail account for a new user
In LINUX, it is very easy to open an e-mail account for a new user. You only need to add a new user in LINUX. The user account and password are the account and password of e-mail.
For example, I open an E-Mail account for a new user test. Run the following command:
Adduser testpasswd test
In this way, the e-mail address of the new user is:
Test@company.com
The password is the account password.
  
6.5.5 set an alias for the e-mail account
If some users want to use multiple email addresses, do they need to open multiple accounts for them? If so, it will increase the difficulty of account management. Therefore, LINUX provides a way to set aliases.
For example, a user named "Wang Daming" wants to have the following e-mail addresses:
Wdm@company.com
Wangdm@company.com
Daming@company.com
Follow these steps to set an alias.
1. log on to the server as root;
2. Add an account, wdm;
3

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.