First, determine whether the server belongs to Ali Cloud, because Ali Cloud has disabled port 25 for security reasons, and you can apply for unlocking port 25 when initiating work orders. However, it is said that this process is long and unreliable, so you have to send emails through encrypted port 465. The specific method is as follows:
Blog.sina.com.cn/s/blog_b953…
I intended to use port 465 to send messages, but after the configuration was completed according to the above procedure, I could not send and receive outland emails normally, and Baidu and Google could not find the reason. The Telnet result is as follows:
Telnet mail.ranger.com 465 Trying IP address Connected to mail.ranger.com. Escape character is '^]'.Copy the code
A normal Telnet would look like this:
Telnet mail.ranger.com 465 Trying IP address Connected to mail.ranger.com. Escape character is '^]' PostfixCopy the code
Connect to mx1.qq.com[58.251.110.111]:25: Connection timed out, why is 465 not used? You should know that at this time ali cloud security station rules added port 465, and the firewall is also open port 465 (in fact, the firewall is still that mistake). Scratching their heads……
Then I found another non-Ali cloud server to set up. Here is the specific process:
Add email domain name resolution records
The host record must be filled with the @ sign, or the message cannot be received.
MX records must precede A records; otherwise, mail cannot be received.
Reference article:
www.comingchina.com/windows/ins…
www.360doc.com/content/11/…
2. Set the host name
/etc/sysconfig/network NETWORKING=yes HOSTNAME=mail.ranger.com # modify your own email address #nano /etc/hosts 127.0.0.1 localhost Mail.ranger.com localhost. Localdomain localhost4 localhost4. Localdomain4Copy the code
Re-open the session and you will find that the host name has changed: [root@mail ~]#
Install the postfix server
Check whether postfix is installed.
# service postfix status
Copy the code
If no instruction is installed:
# yum install postfix
Copy the code
Edit /etc/postfix/main.cf file:
Cf /etc/postfix/main.cf /etc/postfix/main.cf myhostname = mail.ranger.com // Host name mydomain = ranger.com // set the mail domain of the local network myOrigin = $mydomain // Inet_interfaces = all // Set the network port on which Postfix listens Inet_protocols = ipv4 // ipv4 is recommended. If ipv6 is supported, All mydestination = $myhostname, localhost.$mydomain, localhost,$mydomain // Mynetworks = 0.0.0.0/0 // Specifies the IP segment of the local network, Relay_domains = $mydestination; home_mailbox = Maildir; relay_domains = $mydestinationCopy the code
After setting, restart postfix:
# service postfix restart
Copy the code
Test sending:
# userAdd Ranger // Linux creates an email account with the same name. The email account cannot have uppercase letters. Otherwise unable to send and receive email # echo '123456' | passwd -- stdin ranger # # useradd admin echo '123456' | passwd -- stdin admin 2. Using Telnet mail.ranger.com 25 Trying IP address... Connected to mail.ranger.com. Escape character is '^]'. 220 mail.ranger.com ESMTP Postfix HELO mail.ranger.com 250 mail.ranger.com MAIL FROM:[email protected] // Sender address 250 2.1.0OK RCPT TO:[email protected] // Recipient address 250 2.1.5OK DATA End data with <CR><LF>.<CR><LF> Subject:test mail This is a test mail. // This is a test mail. Queued as 508F0104FA00 quit // Quit 221 2.0.0 Bye Connection closed by foreign hostCopy the code
View the receipt in the next module.
Dovecot
# # yum install dovecot - y edit the main configuration file # nano/etc/dovecot/dovecot conf separate protocols = imap/pop3 LMTP/specify this E-mail host listen = run by the agreement * // Listen to all network interfaces of the local host login_trusted_networks = 0.0.0.0/0 // Specify the allowed network segment address # nano /etc/doveco/conf.d/10 -mail.conf mail_location = Maildir :~/ maildir // specifies the mail storage format and location # nano /etc/dovecot/conf.d/10-auth.conf disable_plaintext_auth = no # nano /etc/dovecot/conf.d/10-mail.conf mail_location = maildir:~/Maildir # nano /etc/dovecot/conf.d/10-ssl.conf ssl = noCopy the code
Restart the dovecot
# service dovecot restart # Telnet mail.ranger.com 110 Trying IP address Connected to mail.ranger.com. Escape character is '^]'. +OK Dovecot ready. user admin // enter user name +OK pass 123456 // enter user password +OK Logged in. List +OK 1 messages: 1 1597. Retr 1 // Check the first email +OK 1598 octets // email contents *********** quit +OK Logging out. Connection closed by foreign host.Copy the code
Five, use Foxmail test mailbox
After configuration, you can use Foxmail to provide a small tool to check whether the mailbox can be used normally:
The final test involves sending and receiving both in and out of the domain.