Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build CentOS Postfix Mail Server

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

How to build a CentOS Postfix mail server, I believe that many inexperienced people do not know what to do. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Content of the experiment:

1. Optimization of initial environment

2. Construction of DNS server and resolution of postfix domain name

3. Postfix server installation and simple configuration

4. Simple sending test

The steps of the experiment:

-1. First of all, we need to confirm and improve the initial environment of the experiment.

The native ip address of the server is XXX.XXX.XXX.XXX

[root@localhost ~] # cat / etc/redhat-release / / View the current system version

CentOS Linux release 7.4.1708 (Core)

[root@localhost ~] # vi / etc/hostname / / change the hostname to the mail server domain name mail.emcc.com

[root@localhost ~] # service iptables stop / / prohibit firewall from booting itself

[root@localhost ~] # vi / etc/sysconfig/selinux / / change the value of the uncommented SELINUX line to disabled

[root@localhost ~] # vi / etc/fstab / / Edit the fstab configuration file and add the following on the last line

[root@localhost ~] # vi / etc/yum.repos.d/CentOS-Base.repo / / Edit the configuration file of yum to facilitate subsequent installation

The configuration is as follows, other deletions or comments:

[base]

Name=CentOS-$releasever-Base

Baseurl= file:///mnt

Enabled=1

Gpgcheck=0

[root@localhost ~] # reboot / / restart to make the optimized environment take effect

-2. Set up domain name resolution in DNS environment to resolve postfix addresses-

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

[root@mail ~] # vi / etc/named.conf / / modify DNS main configuration file

Listen-on port 53 {XXX.XXX.XXX.XXX;}

Allow-query {any;}; / / modify the contents of these two lines

[root@mail ~] # vi / etc/named.rfc1912.zones / / modify the subconfiguration file

Zone "emcc.com" IN {

Type master

File "emcc.com.zone"

}

Zone "xx.xxx.xxx.in-addr.arpa" {- IP addresses to these such as 10.0.20.3 are written here as 20.0.10

Type master

File "emcc.com.local"

}; / / add a forward and reverse parsing region at the end

[root@mail ~] # cd / var/named/ enter the DNS server zone configuration file directory

[root@mail named] # cp-p named.localhost emcc.com.zone

[root@mail named] # cp-p named.localhost emcc.com.local / / copy template zone profile is the specified zone profile. Note: be sure to retain the source file permissions, if not, change the group to named.

[root@mail named] # vi emcc.com.zone / / Edit the forward zone configuration file, modify and add the following lines

NS @

A XXX.XXX.XXX.XXX

MX 10 mail.emcc.com

Mail A XXX.XXX.XXX.XXX

[root@mail named] # vi emcc.com.local / / Edit the reverse zone configuration file, modify and add the following lines

@ IN SOA emcc.com rname.invalid. (

NS @

A XXX.XXX.XXX.XXX

MX 10 mail.emcc.com

Xxx (the last number of ip) PTR mail.emcc.com

[root@mail named] # systemctl start named / / start the DNS domain name resolution server

[root@mail named] # yum install-y bind-utils / / install the nslookup command to test whether dns can be parsed successfully

[root@mail named] # vi / etc/resolv.conf / / give the local DNS to point to your own dns server

Nameserver XXX.XXX.XXX.XXX

[root@mail named] # nslookup mail.emcc.com / / resolve the mail server address. The following indicates success

Server: XXX.XXX.XXX.XXX

Address: XXX.XXX.XXX.XXX#53

Name: mail.emcc.com

Address: XXX.XXX.XXX.XXX

-3. Install and configure the postfix server-

As there are many problems with the postfix server, generally, even if you minimize the installation of the CentOS system, the postfix server is automatically installed by default.

[root@mail named] # rpm-Q postfix / / check whether the postfix server has been installed on the system

Postfix-2.10.1-6.el7.x86_64

[root@mail named] # postconf-a / / check whether postfix supports cyrus dovecot, and if not, you need to reinstall the updated version

[root@mail named] # vi / etc/postfix/main.cf / / Edit the configuration file of postfix, find and modify the corresponding configuration items

Myhostname = mail.emcc.com / / native hostname

Mydomain = emcc.com / / server domain name

Myorigin = $mydomain / / initial domain name

Inet_interfaces = XXX.XXX.XXX.XXX, 127.0.0.1 / / listening interface

Inet_protocols = ipv4 / / listens to the network version without changing it

Mydestination = $myhostname, $mydomain / / target domain

Home_mailbox = Maildir/ email directory, under the user's home directory

[root@mail named] # postfix check / / check the configuration file for syntax errors

[root@mail named] # systemctl start postfix / / start the postfix server

/ / postconf-n this command can view the non-default configuration of postfix

-4. Mail server simple mail test-

[root@mail named] # groupadd mailusers / / add email account group

[root@mail named] # useradd-g mailusers-s / sbin/nologin emcc

[root@mail named] # passwd emcc

[root@mail named] # useradd-g mailusers-s / sbin/nologin emcct

[root@mail named] # passwd emcct / / add a test account for emcc/emcct mail service

[root@mail named] # yum install-y telnet / / install the Telnet plug-in for login port 25 testing

[root@mail named] # telnet mail.emcc.com 25 / / remote login port 25. If an error is reported, restart postfix.

Echo "xxxx" | mail-s "title" xxx@163.com

Change (xxxx@163.com) to the email address you want to send

After reading the above, have you mastered how to build a CentOS Postfix mail server? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report