Note: This article's mail server is used only to send mail, that is, the STMP server.
First, preparatory work
1. Add DNS resolution for mail server
Although you can send a message without DNS resolution, it will be treated as spam by most mail servers. According to our practical experience, we need to add three DNS resolution records: A record, MX record, txt record. For example domain name cnblogs.info, the corresponding DNS record is as follows:
2. Prepare the hard disk space to store the mail
If you are using the Aliyun entry-level Linux server, there is a 20G of data disk is not mounted, you need to format and mount (assuming that the directory is mounted here is/data), the specific steps see before the Bovenari server hard disk partition and mount.
Second, configure Postfix
Postfix is the CentOS mail server software that is installed by default. The following configuration example assumes that the domain name to be configured is Cnblogs.info and the mail server host name is Mail.cnblogs.info.
1. Open the Postfix configuration file
Vi/etc/postfix/main.cf
2.: 75 cursor moved to line 75th, modify Myhostname
Myhostname = Mail.cnblogs.info
3.: 83 cursor moved to line 83rd, modify MyDomain
MyDomain = Cnblogs.info
4.: 99 cursor moved to line 99th, modify Myorigin
Myorigin = $mydomain
5.: 116 cursor moved to line 116th, modify Inet_interfaces
Inet_interfaces = All
6.: 119 cursor moved to line 119th, modify Inet_protocols
Inet_protocols = IPv4
7.: 164 The cursor moves to line 164th, add $mydomain
mydestination = $myhostname, localhost $mydomain, localhost, $mydomain
8.: 264 cursor moved to line No. 264, modify Mynetworks
Mynetworks = 127.0.0.0/8
Subnet mask (netmask) Converter: Network and IP address calculator
9.: 419 cursor to move to line No. 419, set Home_mailbox
Home_mailbox = maildir/
10.: 425 the cursor moves to line No. 425, setting Mail_spool_directory,/data is the previously mounted data disk, the mail directory needs to be created by the mkdir command
Mail_spool_directory =/data/mail
11. Reboot postfix to make setting effective
Service Postfix Restart