How to Set up an email server in linux

Source: Internet
Author: User
Tags imap hp server
For more information about how to set up an email server-linux Enterprise Application-Linux server application in Linux, see the following. Setting up an email server
Is it not detailed enough for me to write? The reading comrades give me some comments.
1. first, we need to understand some concepts. The mail server is in a domain. For example, the mail server I created is in the zhaoyong.com domain. The Mail Server can be divided into sending and receiving mails, the tools used for sending emails are smtp, and pop3 and imap are used for receiving emails. As pop3 is gradually eliminated, Here we only learn imap.
When sending a Mail, we use the SMTP (Simple Mail Transfer Protocol) communication Protocol, while when receiving a Mail, we use POP3 (Post Office Protocol) or the IMAP (Internet Message Access Protocol) Protocol.
Generally, the commonly used SMTP software is the Sendmail, Qmail, or Postfix included in FreeBSD. POP3 and IMAP software used for receiving emails
2. First, go to the sendmail official website to download the latest version, www.sendmail.org, http://www.sendmail.org/releases/8.14.1.php. The latest version is 8.14.1. You can download it here.
3. [root @ zy jishu] # rpm-q sendmail ensure that you have not installed sendmail and postfix. If you have installed sendmail, uninstall it.
[Root @ zy jishu] # rpm-q postfix
[Root @ zy jishu] # rpm-e -- nodeps sendmail, -- nodeps ignore dependency information check
Traditionally, SMTP does not require identity authentication when receiving user messages. Anyone can use your host to create spam messages and sendmail does not have its own authentication library, we need to check whether the following authentication library is installed
[Root @ zy jishu] # rpm-qa | grep sasl
Cyrus-sasl-2.1.15-6
Cyrus-sasl-plain-2.1.15-6
Cyrus-sasl-md5-2.1.15-6
Cyrus-sasl-devel-2.1.15-6
If you haven't installed it, go here to download ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
Please note that sendmail requires dns service installation. If your dns is not installed, please refer to my 12th and 13th lessons.
4. You must note that the email server must be in the local area.
[Root @ zy jishu] # more/var/named/zhaoyong.com. zone
@ 1D in soa zhaoyong.com. root (
2007080312
1 H
15 M
1 W
1D)
In ns @
In a 192.168.1.144
In mx 10 mail
Www in a 192.168.1.101
Mail in a 192.168.1.102
News in cname www
Ftp in cname mail

The mail server address here is 192.168.1.102, which ensures dns resolution. MX is Mail Server 10, which indicates priority. The smaller the number, the higher the priority. 5. Then we will compile the main sendmial file.
[Root @ zy jishu] # tar zxvf sendmail.8.14.1.tar.gz unzip this directory
[Root @ zy jishu] # cd sendmail-8.14.1/enter this directory
By default, sendmail does not have a user authentication library.
Edit the following file:
[Root @ zy sendmail-8.14.1] # vi devtools/Site/site. config. m4 then add the following two sentences to compile the SMTP authentication function into sendmail.
APPENDDEF ('confenvdef ','-DSASL = 2 ')
APPENDDEF ('conf _ sendmail_LIBS ','-lsasl2 ') must be clear.
6. Compile the tool.
[Root @ zy sendmail-8.14.1] # sh Build-c Build is a script you can./Build directly execute can also be executed with sh
After compilation, a sendmail daemon is automatically generated.
[Root @ zy sendmail-8.14.1] # sh Build INSTALL it will put the sendmail executable article in the corresponding location
After sendmail is configured, the macro interpreter M4 is required. Are you sure it has been installed?
[Root @ zy sendmail-8.14.1] # rpm-q m4
Since the sendmail configuration is very complex and the syntax is very difficult, we need a macro interpreter. Therefore, when configuring sendmail, you can use the m4 macro configuration.
Sendmail contains a set of macro definitions. Under the cf directory of this directory, We need to cp this directory to the system.
[Root @ zy sendmail-8.14.1] # mkdir/usr/share/sendmail create a directory
[Root @ zy sendmail-8.14.1] # cp-a cf/usr/share/sendmail,-a is the meaning of the entire directory cp
[Root @ zy sendmail-8.14.1] # cd cf/we go to the cf directory of cf
Sendmail requires the sendmail. mc file. In the cf directory, there are different types of sendmail. mc configuration files. We select the linux configuration file.
[Root @ zy cf] # cp generic-linux.mc sendmail. mc copy this file
[Root @ zy cf] # more sendmail. mc: Check this configuration file. There is no space in this file. Note that each line ends with dnl, which means comment.
That is, even if there are spaces, the meaning is commented out.
Divert (0) dnl
VERSIONID ('$ Id: generic-linux.mc, v 8.1 22:48:05 gshapiro Exp $ ')
OSTYPE (linux) dnl
DOMAIN (generic) dnl
MAILER (local) dnl
MAILER (smtp) dnl
[Root @ zy cf] # make install-cf install the sendmail configuration file
Then it prompts you to create a directory.
[Root @ zy cf] # mkdir/etc/mail
[Root @ zy cf] # make install-cf re-run
[Root @ zy cf] # cp sendmail. mc/etc/mail: after cp is added to the mail directory, we only need to change the configuration file to sendmail. mc in the mail directory.
[Root @ zy mail] # cd/etc/mail/enter this directory
[Root @ zy mail] # touch aliases access we first create two initialized files aliases to save the user's alias file access is the address that allows access to the user
[Root @ zy mail] # echo "zhaoyong.com"> the local-host-names statement indicates that the local machine serves the zhaoyongcom domain.
[Root @ zy mail] # echo "zhaoyong.com"> Add local-host-names with redirection
It not only serves the zhaoyong.com domain, but also serves mail.zhaoyong.com.
[Root @ zy mail] # makemap hash access <access because access is an empty file, we use the makemap command to create the file into a database.
-Bash: makemap: command not found: We found that the command failed.
[Root @ zy mail] # which makemap
/Usr/bin/which: no makemap in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin: /sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin)
So we have to go back.
[Root @ zy sendmail-8.14.1] # sh Build INSTALL will sendmail from the new INSTALL guys I am bitter, my Linux kernel does not support makemap I went crazy, the new version of the support is not enough ah, i'm about to unmount the new CD.
[Root @ zy mail] # makemap hash aliases <aliases generates an aliases
[Root @ zy mail] # create such a file by mkdir/var/spool/mqueue. There may be a large number of users who send the file to the server, and a sequence is required.
[Root @ zy mail] #/usr/sbin/sendmail-db-q1h,-db runs in the background-q1h one-hour queue processing, start the server
[Root @ zy mail] # ps-aux | grep sendmail
7. Test
[Root @ zy root] # netstat-tnl | grep: 25 monitors whether port 25 of the local machine is running
Create a user to receive and send emails
[Root @ zy root] # useradd redhat
[Root @ zy root] # passwd redhat
Note that the root user cannot use the smtp protocol to receive and send emails.
It's not going to be continued. My friends supported me. raid5 screwed me up, and the rotten HP Server will be installed again tomorrow.
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.