Configure postfix email in Centos Environment

Source: Internet
Author: User
Tags dovecot mx record

Configure postfix email in Centos Environment

I. Basic concepts of mail

1. Email Service Agreement:
A) SMTP: Slmple Mail Tansfer Protocol (Simple Mail Transfer Protocol) Port: 25 (sent)
ESMTP: Extended (check can be implemented)
B) POP3: Post Office Protocol (Post Office Protocol 3) Port: 110 (accept)
IMAP4: Internet Mail Access Protocol (four generations of Internet Mail Access Protocol)
C) SASL: Slmple Authlntcation Secure Layer (simple authentication security Layer)
2. email relay: Transfers user mail to the recipient's email server through multi-link SMTP mail forwarding server without changing the user's email address (sender.
3. Role
A) MTA: mail Transmission proxy, SMTP Server
Program: sendmail (uucp), qmail, potfix, exim, Exchange (windows)
B) MDA: mail delivery agent
Program: procmail (sendmail), maildrop,
C) MRA: email retrieval proxy (pop3 and imap4)
Program: cyrus-imap, dovecot
D) MUA: email user proxy
Program: Outlook Express (Lite version), Outlook (Professional version), Foxmail, Thunderbird (Linux), mutt (Linux)
4. webmail: Openwebmail, Squirrelmail, and Extmail (extman management system ,)

2. email server Construction

1. Modify the Host Name:

[root@CXM ~]# hostname mail.cxm.com[root@CXM ~]# vim /etc/sysconfig/networkNETWORKING=yesHOSTNAME=mail.cxm.com

From the New login, you can see the result. 2. Configure DNS (you need to configure DNS for the forward and reverse solutions)

[root@mail ~]# yum -y install bind

Configure the DNS master configuration file

[Root @ mail ~] # Vim/etc/named. conf options {listen-on port 53 {any ;}; # listening port listen-on-v6 port 53 {:: 1 ;}; directory "/var/named "; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt "; memstatistics-file "/var/named/data/named_mem_stats.txt"; allow-query {any ;}; # recursion yes;

Modify the region configuration file of DNS

[Root @ mail ~] # Cp-p/etc/named. rfc1912.zones/etc/named. rfc1912.zones. bak # copying the region configuration file prevents incorrect modification [root @ mail ~] # Vim/etc/named. rfc1912.zoneszone "cxm.com" IN {# domain type master; file "cxm. localhost "; # Set the name of the forward parsing data file allow-update {none ;};}; zone" 1.168.192.in-addr. arpa "IN {# anti-write type master for the IP address; file" cxm. empty "; # Set the reverse resolution data file name allow-update {none ;};}; modify the DNS data file [root @ mail ~] # Cd/var/named/[root @ mail named] # cp-p named. localhost cxm. localhost [root @ mail named] # cp-p named. empty cxm. empty [root @ mail named] # vim cxm. localhost # modify the forward resolution File $ TTL 1D @ in soa cxm.com. rname. invalid. (# domain (remember to include .) 0; serial 1D; refresh 1 H; retry 1 W; expire 3 H); minimum NS dns.cxm.com. # dns MX 10 mail.cxm.com. # MX record resolution mail domain name dns A 192.168.1.24 mail A 192.168.1.24 [root @ mail named] # vim cxm. empty # modify the reverse resolution File $ TTL 3H @ in soa cxm.com. rname. invalid. (# domain 0; serial 1D; refresh 1 H; retry 1 W; expire 3 H); minimum NS dns.cxm.com. 24 PTR dns.cxm.com. 24 PTR mail.cxm.com.

Start the DNS server

[root@mail named]# service named restart

DNS Server

[root@mail ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 DNS1=192.168.1.24

Restart Nic

[root@mail named]# service network restart

Test

[root@mail ~]# nslookup > mail.cxm.comServer:     192.168.1.24Address:    192.168.1.24#53Name:   mail.cxm.comAddress: 192.168.1.24> 192.168.1.24Server:     192.168.1.24Address:    192.168.1.24#5324.1.168.192.in-addr.arpa   name = mail.cxm.com.24.1.168.192.in-addr.arpa   name = dns.cxm.com.

2. install and configure postfix

If the built-in mail software is sendmail, uninstall sendmail first. Install postfix. My system is Centos6.5's experimental environment, and my built-in mail software is postfix.

[Root @ mail ~] # Service sendmail stop [root @ mail ~] # Chkconfig sendmail off [root @ mail ~] # Rpm-e sendmail -- nodeps # uninstall dependency [root @ mail ~] # Rpm-q postfix postfix-2.6.6-2.2.el6_1.x86_64 # the postfix is installed by default (but the default postfix installation does not support SASL, only the plaintext password you note)

Modify the postfix configuration file main. cf

[Root @ mail ~] # Vim/etc/postfix/main. cf myhostname = mail. cxm. commydomain = cxm. commyorigin = $ myhostnamemyorigin = $ mydomainmydestination = $ myhostname, localhost. $ mydomain, localhost, $ mydomain # home_mailbox = Maildir/# mail placement location. The default value is mailbox. Dovecot also supports mailbox by default, so it is not changed here # Mailbox stores all emails in a file # Maildir stores one email in a file, one directory for all email storage, inet_interfaces = all # mynetworks = 192.168.1.0/24,127.0 .0.0/8 #, indicates that the relay is not changed, and no relay is provided for anyone.

Restart postfix to make the configuration take effect

[Root @ mail ~] # Service postfix restart disable postfix: [OK] Start postfix: [OK]

Test whether you can send emails (but cannot receive emails now) to add users.

[root@mail ~]# useradd cxm[root@mail ~]# passwd cxm[root@mail ~]# useradd ts[root@mail ~]# passwd ts

Install telnet Test

[root@mail ~]# yum -y install telnet

Test (view logs)

[Root @ mail ~] # Telnet mail.cxm.com 25 # connect to port Trying 192.168.1.24 of mail.cxm.com... connected to mail.cxm.com. escape character is '^]'. 220 mail.cxm.com ESMTP Postfix helo mail.cxm.com 250 mail.cxm.com mail from: cxm@cxm.com # sender 250 2.1.0 Okrcpt to: ts@cxm.com # recipient 250 2.1.5 Okdata # title 354 End data with <CR> <LF>. <CR> <LF> test. # End 250 2.0.0 OK: queued as 2AE424073Fquit # exit 221 2.0.0 ByeConnection closed by foreign host.

View logs

[Root @ mail ~] # Tail/var/log/maillogMar 6 20:52:23 localhost postfix/smtpd [24832]: 2AE424073F: client = mail.cxm.com [192.168.1.24] Mar 6 20:52:37 localhost postfix/cleanup [24844]: 2AE424073F: message-id = <20170306125223.2AE424073F@mail.cxm.com> Mar 6 20:52:37 localhost postfix/qmgr [24714]: 2AE424073F: from = <cxm@cxm.com>, size = 325, nrcpt = 1 (queue active) mar 6 20:52:37 localhost postfix/local [24845]: 2AE424073F: to = <ts@cxm.com>, relay = local, delay = 76, delays = 76/0. 09/0/0.03, dsn = 2.0.0, status = sent (delivered to mailbox) # If the status is sent, it indicates that Mar 6 20:52:37 localhost postfix/qmgr [24714]: 2AE424073F: removedMar 6 20:52:50 localhost postfix/smtpd [24832]: disconnect from mail.cxm.com [192.168.1.24]

Install dovecot to modify the configuration

[Root @ mail ~] # Yum-y install dovecot [root @ mail ~] # Vim/etc/dovecot. conf protocols = imap pop3 # support Protocol [root @ mail ~] # Vim/etc/dovecot/conf. d/10-auth.conf disable_plaintext_auth = no # Allow plaintext password verification [root @ mail ~] # Vim/etc/dovecot/conf. d/10-mail.conf mail_location = mbox :~ /Mail: INBOX =/var/mail/% u [root @ mail ~] # Su-cxm # Switch user [cxm @ mail ~] $ Mkdir-p ~ /Mail/. imap/INBOX # create a directory [cxm @ mail ~] $ Su-ts password: [ts @ mail ~] $ Mkdir-p ~ /Mail/. imap/INBOX [ts @ mail ~] $ Su-root Password: [root @ mail ~] #

Restart dovecot to make the configuration take effect.

[Root @ mail ~] # Service dovecot start is starting Dovecot Imap: [OK]

Use the client software to test whether foxmail can be sent and received as follows:
Windows Live Mail settings are as follows:
Test

An email is sent to verify that the test is successful.

Iii. common error messages for configuring postfix in Centos environment 1. generating/etc/rndc appears when DNS is started. key: solved here: [root @ mail named] # rndc-confgen-r/dev/urandom-a 2. telnet cannot connect to the domain name + port 25, but can connect to the localhost + port 25, it may be because no DNS is specified, or the service is not restarted after the specified 3. foxmail and win live mail may not be created on the specified user ~ The/mail/. imap/INBOX directory may not be switched to the user-created directory because the owner and group of the Directory are the corresponding users.

[Root @ mail ~] # Ls-l/home/cxm/mail /. imap/INBOX/total usage 20-rw -------. 1 cxm 16384 March 6 21:44 dovecot. index. cache-rw -------. 1 cxm 704 March 6 21:44 dovecot. index. log

4. An error occurred while reading the log file after modifying the foxmail and dovecot configuration files. The log file can be clearly written, searched online, or commented. Let's discuss [root @ mail ~] # Tail-f/var/log/maillog

This is a simple email server and is not secure enough. In the future, other open-source email servers, such as EXTMAIL, will be updated. You can configure the email receiving server on the browser.

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.