How to Set up a Linux email server

Source: Internet
Author: User
Tags imap email account linux text editor mailc qmail

In today's society, network security is becoming more and more important, especially when we send and receive emails. How can I set up a mail server. We use Red Hat Linux 9.0 as an example. The Linux Mail server suites available in Linux include Sendmail and Qmail. I hope you will learn how to set up a Linux email server.

Qmail focuses more on security issues. If you need a secure email gateway, it is a good option; sendmail has certain characteristics in terms of stability, portability, and bug-free. In addition, you can find a lot of useful materials on the network. Therefore, this system is generally used in Linux, this article is based on Sendmail.

1. Install Sendmail

When Red Hat Linux 9.0 is fully installed, Sendmail is automatically built in with the version 8.12.8-4. If you are not sure whether sendmail is installed in Linux, run the following command to check whether sendmail is installed:
[Root @ ahpeng root] rpm-qa grep sendmail

If you are sure that the application is not installed, choose "Main Menu"> "system settings"> "add or delete application" in the graphic interface ", select the mail server option in the open "software package management" window, click "Update", and follow the prompts to install it.

Another way is to insert the Linux 1st installation CD directly, select the sendmail-8.12.8-4.i386.rpm installation package under the/RedHat/RPMS directory, then run [root @ ahpeng RPMS] # rpm-ivh sendmail-8.12.8-4.i386.rpm to start installation, and then use this method to install sendmail-cf.8.12.8-4.i386.rpm and sendmail-doc in the same directory of the 3rd installation discs. 8.12.8-4. i386.rpm.

Ii. Start the Sendmail service system

We recommend that you use the Sendmail command with parameters to control the running of the mail server: [root @ ahpeng root] # sendmail-bd-q12h, which is explained as follows:

-B: Set the Sendmail service to run on the background.
-D: Specify Sendmail to run in Daemon mode.
-Q: When Sendmail fails to send emails, the emails are saved in the queue and the storage time is specified. The above 12 hours indicates that the data is retained for 12 hours.

In addition, to check whether the Sendmail server is running properly, run the command line [root @ ahpeng root] #/etc/rc. d/init. d/sendmail status.

3. configure Sendmail

Sendmail. the configuration Syntax of cf is relatively difficult. Generally, m4 macro processing programs are used to generate the required sendmail. cf files (using m4 compilation tools is generally not prone to errors, and some macros with security vulnerabilities can be prevented from causing damage to the server ). The configuration file is located in/etc/mail/sendmail. cf. a template file is also required during the creation process. Linux has a template file, which is located in/etc/mail/sendmail. mc. Therefore, you can directly modify the sendmail. mc template to customize the sendmail. cf file, without having to stick to configuration commands that are hard to understand. The configuration steps are as follows:

Step 1: use the template file sendmail. mc generates sendmail. the cf configuration file is exported to the/etc/mail/directory and the command behavior is m4/etc/mail/sendmail. mc>/etc/mail/sendmail. cf

Step 2: restart sendmail with the [root @ ahpeng root]/etc/rc. d/init. d/sendmail restart command line.

At this point, the mail service system has been configured and is working properly. The next step is to create a specific account.

4. Create a new email account

This step is relatively simple. You only need to add a user in Linux. Choose "Main Menu"> "system settings"> "users" and "group". Then, open the "Red Hat User Manager" dialog box and click "Add User, in the "Create new user" window that appears, enter the user name and password ,:

The command line is [root @ ahpeng root] # adduser mailA-p Pass, indicating that a mailA account is created and the password is Pass.

5. Limit the mailbox capacity of a single user

If the user's mail capacity is not limited, the server's hard disk is overwhelmed. This can be achieved through the "mail quota" function: Because the temporary storage space for email is located in the/var/spool/mail directory, therefore, you only need to set the maximum space that each email account can use in this directory through the disk quota.

6. set multiple email addresses for a single user

The alias (alias) can be used to solve this problem. Aliases are one of the most important functions of sendmail. It is defined in the aliases text file. The location of the aliases file is specified by sendmail. cf, which is generally located in the/etc directory. For example, the mailA user we created earlier needs to have 2 email addresses: mailA@yourdomain.com and mailB@yourdomain.com, which can be set like this:

First, add an account mailC and use the Linux text editor to open/etc/aliases. Add the following command lines: dearpeter: mailC and truepeter: mailC; then run the newaliases command in the Command window to require Sendmail to re-read the/etc/aliases file. If it is correct, a response message is displayed, indicating that the configuration is successful. In this way, two addresses can be used to send emails to mailC, while mailC can receive all emails sent to the preceding two addresses with only one account.

After the preceding steps, you can use Outlook Express to send emails normally. However, you cannot use Outlook Express to receive emails from the server, because sendmail does not have the POP3 function by default, we have to install and enable it on our own.

1. Install POP3 (IMAP) Server

Step 1: run the following command to check whether the system is installed:
[Root @ ahpeng root] # rpm-qa imap
Imap-2001a-18

Step 2: insert 2nd installation discs and use the following command line to start installation:
[Root @ ahpeng root] # cd/mnt/cdrom/RedHat/RPMS
[Root @ ahpeng root] # rpm-ivh imap-2001a-18.i386.rpm

2. Enable the POP3 (IMAP) Service

POP3 Service: Modify/etc/xinetd first. in the d/ipop3 file, change "disable = yes" to "disable = no" and save the modification. Then restart the xinetd program to read the modified configuration file and make it take effect:
[Root @ ahpeng root] #/etc/rc. d/init. d/xinetd reload
The procedure for starting the IMAP service is the same as that for POP3, but the IMAP configuration file is/etc/xinetd. d/imap. After completing the above steps, your Linux is already a Linux email server! I hope this article will help you.

  1. Analysis on Suse Linux under vm
  2. Preschool guidance: SUSE Linux
  3. Abbreviations in SUSE Linux
  4. Operation Manual: Install the RDAC driver in SUSE
  5. Your Chameleon: Open Suse

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.