Linux system installation configuration postfix mail Server tutorial

Source: Internet
Author: User
Tags imap centos dovecot mx record

One, install POSTFIX,CYRUS-SASL,CYRUS-IMAPD

If the YUM hint cannot find the package, please change the source, please refer to CentOS 6 recommended to use Epel source

The code is as follows:

[Root@localhost ~]# Yum install postfix

[Root@localhost ~]# Yum Install cyrus*

Two, removed the SendMail

The code is as follows:

[Root@localhost ~]# rpm-e SendMail

Or

The code is as follows:

[Root@localhost ~]# Yum Remove SendMail

Third, change the default message transfer agent (MTA)

The code is as follows:

[root@localhost sasl2]# Alternatives--config MTA

A total of 1 programs provide "MTA".

Select command

-----------------------------------------------

*+ 1/usr/sbin/sendmail.postfix

Press Enter to save the current selection [+], or type the selection number: 1

Only one of the postfix,sendmail has been deleted by me. You can view it by following the command.

The code is as follows:

[root@localhost ~]# Alternatives--display MTA

Four, POSTFIX,CYRUS-SASL,CYRUS-IMAPD related configuration

1,postfix Master configuration file main.cf

The code is as follows:

[Root@localhost postfix]# VIM/ETC/POSTFIX/MAIN.CF

Myhostname = localhost//76 line, overwriting the part following the equals sign to the native host name

mydomain = 51yip.com//82 line, setting the domain name

Myorigin = $mydomain//97 line, change $myhostname to $mydomain

Inet_interfaces = All//112 line, change the localhost back to all

mydestination = $myhostname, localhost $mydomain, localhost, $mydomain//163 line, take off the preceding note, and add the $mydomain

Mynetworks = 192.168.0.0/24, 127.0.0.0/8//263 line, set intranet and local IP

Local_recipient_maps =//209 line, take off the preceding note.

Smtpd_banner = $myhostname ESMTP unknow//568 Line, take off the preceding note and change $mail_name ($mail _version) to Unknow

< p>//Add the following at the bottom of the main.cf file

Smtpd_sasl_auth_enable = yes//Use SMTP authentication

Broken_sasl_auth_clients = yes//Let smtpclient that do not support RFC2554 can also interact with postfix.

Smtpd_sasl_local_domain = $myhostname//Specify the SMTP authenticated local domain name

Smtpd_sasl_security_options = noanonymous//Cancel Anonymous login mode

Smtpd_recipient_restrictions = Permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination// Set restrictions on the recipient portion of a message

Smtpd_sasl_security_restrictions = Permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination//Set allowable range

Message_size_limit = 15728640//message size

MAILBOX_TRANSPORT=LMTP:UNIX:/VAR/LIB/IMAP/SOCKET/LMTP//Set the path of the connection CYRUS-IMAPD

If you do not add local_recipient_maps this configuration, the receipt of mail is not received, the following is the return of QQ letter.

The recipient mail address (tank@51yip.com) does not exist and the message is undeliverable. Host mail.51yip.com[122.225.***.***] said:550 5.1.1:recipient address rejected:user unknown to local recipient table (I n Reply to RCPT to command)

2,CYRUS-SASL Configuration

The code is as follows:

[Root@localhost postfix]# vim/etc/sasl2/smtpd.conf//Add the following to the end of the file

Log_level:3//Log mode

Saslauthd_path:/var/run/saslauthd/mux//Set the path for the SMTP search CYRUS-SASL, where the 32-bit machine and the 64-bit machine smtpd.conf path are not the same.

< p>//This is the SMTPD configuration file on the CentOS 5.5 32-bit machine

[Root@linux sasl2]# ls |grep conf

Sendmail.conf

Smtpd.conf

[Root@linux sasl2]# pwd

/usr/lib/sasl2

This is the SMTPD configuration file on the CentOS 6.0 64-bit machine, and there are no smtpd profiles anywhere else.

[Root@localhost postfix]# ls/etc/sasl2/|grep smtpd

Smtpd.conf

There are a lot of postfix installation articles on the Internet, the configuration is not explicitly proposed is 32-bit machine, or 64-bit machine. So mark it here.

3, configure CYRUS-IMAPD

The main configuration file for CYRUS-IMAPD has the following three

The code is as follows:

/etc/sysconfig/cyrus-imapd

< p>/etc/cyrus.conf

< p>/etc/imapd.conf

This is the default configuration, which means I haven't moved the three files above. Here's a reminder imapd.conf in this file, you can set up admin account

, set up the mail storage directory, set the password to connect the way and so on.

Five, start POSTFIX,CYRUS-SASL,CYRUS-IMAPD

Start the CYRUS-IMAPD service, you can provide both POP and IMAP services, if you have installed the Dovecot service can be deleted, CYRUS-IMAPD and Dovecot choose one of the two, can provide POP and IMAP services, However, CYRUS-IMAPD can create a message for each user, and the mailbox has a hierarchical structure, better management. It is recommended to use CYRUS-IMAPD.

The code is as follows:

[Root@linux sasl2]#/etc/init.d/postfix start

[Root@linux sasl2]#/ETC/INIT.D/SASLAUTHD start

[Root@linux sasl2]#/ETC/INIT.D/CYRUS-IMAPD start

Look at the process,

The code is as follows:

SMTP Listening is port 25

[Root@linux u]# netstat-tpnl |grep smtpd

TCP 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 6319/smtpd

The code is as follows:

(POP3) and 143 (IMAP) ports, all of which are available below

[Root@linux u]# NETSTAT-TPNL |grep Cyrus

TCP 0 0 0.0.0.0:993 0.0.0.0:* LISTEN 23593/cyrus-master

TCP 0 0 0.0.0.0:995 0.0.0.0:* LISTEN 23593/cyrus-master

TCP 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 23593/cyrus-master

TCP 0 0 0.0.0.0:2000 0.0.0.0:* LISTEN 23593/cyrus-master

TCP 0 0::: 993:::* LISTEN 23593/cyrus-master

TCP 0 0::: 995:::* LISTEN 23593/cyrus-master

The TCP 0 0::::::* LISTEN 23593/cyrus-master

TCP 0 0::: 143:::* LISTEN 23593/cyrus-master

TCP 0 0:: £ º::* LISTEN 23593/cyrus-master

Startup is no problem.

Six, Test CYRUS-SASL

The code is as follows:

[Root@linux t]# passwd Cyrus//Set Cyrus password

[Root@linux sasl2]# testsaslauthd-u cyrus-p ' Hu Jintao '/system user and password

0:ok "Success."

If it appears to be the above, it's SMTP.

Seven, CYRUS-IMAPD production mail Administrator account, and add test account

After the installation of CYRUS-IMAPD will produce a management account is Cyrus, the user group is mail

The code is as follows:

[Root@linux sasl2]# ID Cyrus//imapd.conf The default administrator account is Cyrus

Uid=76 (Cyrus) gid=12 (mail) groups=12 (mail), (Saslauth)

In the authentication admin account, I found that 32-bit system and 64-bit system is a little different, two kinds of systems I have configured, configuration is the same,

But the result is different, look at the picture below

32-bit Machine Cyrus Administrator user authentication

64-bit Machine Cyrus Administrator user authentication

From the above figure can be seen, 32-bit system is not to add--auth plain,64 bit, if not added, simply can't go.

After we go in, we'll add the test account.

The code is as follows:

[Root@linux sasl2]# cyradm-u Cyrus localhost

IMAP Password:

localhost> cm tank

Localhost> LM

Tank (Hasnochildren)

Localhost> quit

So we can see in the/var/spool/imap, the generated directory, 32-bit machine and 64-bit machine-generated directory is not the same

The code is as follows:

This is a 64-bit system-generated directory

[Root@localhost u]# ls

User^tank

[Root@localhost u]# pwd

/var/spool/imap/u

This is a 32-bit system-generated directory

[Root@linux t]# ls

Tank

[Root@linux t]# pwd

/var/spool/imap/t

Eight, test and send and receive mail

Add DNS before testing,

1,mail.51yip.com A Default 122.225.***.***

2,mail.51yip.com A Unicom 60.12.***.***

3,@ MX Default mail.51yip.com

1th and 2nd, is to add two a record, the third line, set the MX record, this must not forget, otherwise your domain name is not pass.

There are a lot of methods, we can use Telnet to test, but use Telnet to test and send and receive mail more trouble, with Linux from the

Mail commands are much more convenient.

The code is as follows:

[Root@localhost u]# mail-s ' see ' 95219454@qq.com </etc/imapd.conf

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.