RedHatLinux9 -- set up an email server

Source: Internet
Author: User
Tags imap email account
RedHatLinux9 -- set up the mail server -- Linux Enterprise Application-Linux server application information. The following is a detailed description.

1. Install Sendmail

If Red Hat Linux 9.0 is fully installed, the system has a built-in Sendmail 8.12.8-4 server. If you cannot determine whether sendmail has been installed, enter the following command in the terminal command window:

[Root @ ahpeng root] rpm-qa grep sendmail

If the result shows as a sendmail-8.12.8-4, it indicates that the sendmail server is installed. If the Sendmail server is not selected when Red Hat Linux 9.0 is installed, you can click the "Main Menu> system Settings> add or delete application" menu item in the graphic environment, in the open "software package management" dialog box, ensure that the "Mail Server" option is selected, and then click the "Update" button. Follow the on-screen prompts to insert the first installation disc to start installation.

Alternatively, you can insert 1st installation discs, locate the sendmail-8.12.8-4.i386.rpm installation package under the/RedHat/RPMS directory, and then run the following command in the terminal command window to start the installation process:

[Root @ ahpeng RPMS] # rpm-ivh sendmail-8.12.8-4.i386.rpm

Install sendmail-cf.8.12.8-4.i386.rpm, sendmail-doc. 8.12.8-4. i386.rpm in the/RedHat/RPMS directory of 3rd installation discs in a similar way.

2. Start/restart/stop the Sendmail service

After installing the Sendmail server, run the following command in the terminal command window:

[Root @ ahpeng root]/etc/rc. d/init. d/sendmail start

The following results should be displayed, indicating that the email server has been started successfully:

Start sendmail: [OK]

Start sm-client: [OK]

In addition to the preceding method, you can use the Sendmail command with parameters to control the running of the mail server. For example:

[Root @ ahpeng root] # sendmail-bd-q1h

The command parameters of Sendmail are described as follows:

-B: Specify Sendmail to run in the background and listen to requests on port 25.

-D: Specify Sendmail to run in Daemon mode (daemprocess ).

-Q: When Sendmail fails to send the email to the destination, it stores the email in the queue. This parameter specifies the time when the message is saved in the queue. In this example, 1 h indicates that the data is retained for 1 hour.

Run the following command in the terminal command window to restart the Sendmail service:

[Root @ ahpeng root] #/etc/rc. d/init. d/sendmail restart

Run the following command in the terminal command window to close the Sendmail service:

[Root @ ahpeng root] #/etc/rc. d/init. d/sendmail stop

You can also run the following command in the terminal command window to check the running status of the Sendmail server:

[Root @ ahpeng root] #/etc/rc. d/init. d/sendmail status

The system should display:

Sendmail (pid 3251) is running...

3. configure Sendmail

The configuration of Sendmail is very complex. Its configuration file is sendmail. cf, which is located in the/etc/mail directory. Due to the profound Syntax of sendmail. cf, few users directly modify the file to configure the Sendmail server. We generally use the m4 macro processing program to generate the required sendmail. cf file. A template file is also required during the creation process. The system defaults to/etc/mail

The directory contains a sendmail. mc template file.

You can generate the sendmail. cf file based on the simple and intuitive sendmail. mc template without directly editing the sendmail. cf file. You can directly modify the sendmail. mc template to customize the sendmail. cf file. This section describes how to create a sendmail. cf file:

(1) back up the original sendmail. cf file

Run the following command in the terminal command window:

Cp/etc/mial/sendmail. cf/etc/mail/sendmail. cf. BAK

(2) generate the sendmail. cf file

Generate the sendmail. cf configuration file based on the sendmail. mc template file and export it to the/etc/mail/directory:

M4/etc/mail/sendmail. mc>/etc/mail/sendmail. cf

(3) restart the sendmail service.

[Root @ ahpeng root]/etc/rc. d/init. d/sendmail restart

Obviously, it is convenient to use the m4 macro compilation tool to create the sendmail. cf file, which is not prone to errors and can avoid damages caused by some macros with security vulnerabilities or outdated macros. The general content of a sendmail. mc template is as follows:

Divert (-1) dnl

......

Include (/usr/share/sendmail-cf/m4/cf. m4) dnl

VERSIONID (setup for Red Hat Linux) dnl

OSTYPE (linux) dnl

......

Dnl #

Dnl define (SMART_HOST, smtp. your. provider)

Dnl #

Define (confDEF_USER_ID, 8:12) dnl

Define (confTRUSTED_USER, smmsp) dnl

Dnl define ('confauto_rebuild ') dnl

......

The syntax of the sendmail. mc template is described as follows:

Dnl: Used to annotate items, and the dnl command is also used to mark the end of a command.

Divert (-1): located at the top of the mc template file, to make the m4 program output more streamlined.

OSTYPE (OperationSystemType): defines the operating system type used. Obviously, linux should be used to replace OperationSystemType. Note that a back quotation mark and a positive quotation mark should be used to enclose the corresponding operating system type.

Define: defines some global settings. For Linux systems, after setting OSTYPE, you can define the following global parameters. If not, use the default value. Here are two simple examples: define (ALIAS_FILE,/etc/aliases)

Defines the Save path of the alias file. The default value is/etc/aliases.

Define (STATUS_FILE,/etc/mail/statistics)

Sendmail status information file.

4. open an email account for the new user

In Linux, it is relatively simple to open an email account for new users. You only need to add a new user in Linux. Click the "Main Menu> system Settings> users and groups" menu to open

In the Red Hat User Manager dialog box, click the Add User button and specify the user name and logon password in the create new user dialog box, as shown in figure 1.

Assume that we have added a user Peter (with the password peter) so that the user has an email address Peter@YourDomain.com (YourDomain.com here is replaced by your own domain name ).

You can also run the following command in the terminal command window to implement the above process:

[Root @ ahpeng root] # adduser peter-p peter

5. Set an alias for the email account

If you want to use multiple email addresses, do you need to create multiple email accounts? We can use the alias (alias) to solve this problem.

For example, peter wants to have the following three email addresses:

Peter@YourDomain.com,

Dearpeter @ YourDomain.com and truepeter @ YourDomain.com.

You can perform the following steps to set an alias:

Add an account peter. Then open/etc/aliases in a text editor such as vi or Kate and add two lines to it:

Dearpeter: peter

Truepeter: peter

Save/etc/aliases and exit.

However, Sendmail cannot accept the new alias. We must run the newaliases command in the terminal command window to request Sendmail to re-read the/etc/aliases file. If everything is correct, you can see a Response Message similar to the following:

[Root @ ahpeng root] # newaliases

/Etc/aliases: 63 aliases, longest 10 bytes, 625 bytes total

In this way, the mail sent to peter can use three mail addresses, while peter only needs to use an email account peter@YourDomain.com to receive all the emails sent to the above three addresses.

6. Specify the mailbox Capacity Limit

When a mail server provides mail services for many people, an unlimited number of emails can easily fill the server's hard disk, causing a hard disk burden. If you do not want to provide unlimited temporary storage space for emails, you can use "mail quota" to provide users with a limited temporary storage space.

In fact, it is achieved by using the disk quota function. The temporary storage space for email is in the/var/spool/mail directory. You only need to set the maximum space that each user can use in this directory through the disk quota.

7. Support for POP and IMAP Functions

So far, we can use Outlook Express to send emails, or log on to the server to use mail and pine commands to receive and manage emails. However, you cannot use clients such as Outlook Express to download emails from the server. This is because Sendmail does not have the POP3 (IMAP) function, so we must install it on our own.

(1) install POP and IMAP servers

When installing Red Hat Linux 9.0, you can install the POP and IMAP servers. You can run the following command in the terminal command window to verify the installation:

[Root @ ahpeng root] # rpm-qa imap

Imap-2001a-18

If no installation is available, you can put 2nd installation discs into the optical drive, and then run the following command in the terminal command window to start installation:

[Root @ ahpeng root] # cd/mnt/cdrom/RedHat/RPMS

[Root @ ahpeng root] # rpm-ivh imap-2001a-18.i386.rpm

Since Red Hat Linux 9.0 has packaged POP and IMAP into a separate suite, installing the imap-2001a-18.i386.rpm will install both servers at the same time

(2) Start POP and IMAP services

To successfully start the POP and IMAP servers, you must first determine that these services exist in the/etc/services file and ensure that the following services are not preceded by # annotations (if any, annotations must be removed ).

Imap 143/tcp imap2 # Interim Mail Access Proto v2

Imap 143/udp imap2

Pop2 109/tcp pop-2 postoffice # POP version 2

Pop2 109/udp pop-2

Pop3 110/tcp pop-3 # POP version 3

Pop3 110/udp pop-3

After modifying the/etc/services file, you need to customize the corresponding service configuration file:

To start the POP3 service, you must modify the/etc/xinetd. d/ipop3 file, change "disable = yes" to "disable = no", and save the file. Finally, you must restart the xinetd program to read the new configuration file so that the configuration content takes effect:

[Root @ ahpeng root] #/etc/rc. d/init. d/xinetd reload

To start the IMAP service, you must modify the/etc/xinetd. d/imap file, change "disable = yes" to "disable = no", and save the file. Finally, you must restart the xinetd program to read the new configuration file so that the configuration content takes effect:

[Root @ ahpeng root] #/etc/rc. d/init. d/xinetd reload

After setting up, you can set up an email account in Outlook Express, and then you can directly use the Sendmail server to send and receive emails. Because the mail server is on the local LAN, the speed is very fast.
Related Article

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.