PrefaceDue to the excessive volume of zabbix monitoring alarm emails sent by the company, the Tencent corporate mailbox used may miss or refuse to send due to excessive sending frequency, so now we use a self-built intranet mail server to send zabbix alarm emails. The intranet's alarm mail server can only send mails to other mailboxes (Tencent corporate mailbox, NetEase mailbox, etc.), but cannot receive replies from other mailboxes. If you want to receive replies, you need to purchase a domain name and configure A records and MX records. This document will not explain this. 1. Configure intranet DNS A record and MX recordThe domain name host I use in my intranet is dnsmasq proxy software, which is simple, convenient and diverse to use. For detailed configuration, please refer to other documents. [root@dns_proxy ~]# grep liqing /etc/dnsmasq.conf address=/mail.liqing-test.top/192.168.2.100 mx-host=liqing-test.top,mail.liqing-test.top,10 2. Initialization configuration of mail server1. Change the host name[root@localhost /]# hostnamectl --static set-hostname mail.liqing-test.top|bash 2. Turn off firewall and selinux[root@mail /]# systemctl stop iptables && systemctl disable iptables [root@mail /]# systemctl stop firewalld && systemctl disable firewalld [root@mail /]# setenforce 0 3. Enable time synchronization[root@mail /]# yum -y install ntpdate && ntpdate ntp.aliyun.com 4. Install the software[root@mail /]# yum -y install postfix dovecot cyrus-sasl-* mailx 3. Modify the configuration fileNote: The configuration file backup operation is performed by yourself in this document 1 Configure postfix[root@mail /]# cat /etc/postfix/main.cf mail_owner = postfix myhostname = mail.liqing-test.top mydomain = liqing-test.top myorigin = $mydomain inet_interfaces = all inet_protocols = ipv4 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain, www.$mydomain, ftp.$mydomain local_recipient_maps = mynetworks = 0.0.0.0/0 relay_domains = $mydestination alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases smtpd_banner = $myhostname ESMTP # Add smtpd_sasl_type = dovecot at the bottom smtpd_sasl_path = private/auth smtpd_sasl_local_domain = smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated smtpd_client_restrictions = permit_sasl_authenticated 2 Configure dovecot2.1 Configure the monitoring protocol:[root@mail /]# cat /etc/dovecot/dovecot.conf protocols = imap pop3 lmtp listen = * login_trusted_networks = 0.0.0.0/0 dict { } !include conf.d/*.conf !include_try local.conf 2.2 Configure login method:[root@mail /]# cat /etc/dovecot/conf.d/10-auth.conf disable_plaintext_auth = no auth_mechanisms = plain login !include auth-system.conf.ext 2.3 Configure the email storage location:[root@mail /]# cat /etc/dovecot/conf.d/10-mail.conf mail_location = mbox:~/mail:INBOX=/var/mail/%u namespace inbox { inbox = yes } first_valid_uid = 1000 mbox_write_locks = fcntl [root@mail /]# cat /etc/dovecot/conf.d/10-master.conf service auth { unix_listener /var/spool/postfix/private/auth { mode = 0666 user = postfix group = postfix } } 2.4 Configure SSL (off):[root@mail /]# cat /etc/dovecot/conf.d/10-ssl.conf ssl = no 3 Configure sasl23.1 Configure system authentication:[root@mail /]# cat /etc/sysconfig/saslauthd SOCKETDIR=/run/saslauthd MECH=shadow FLAGS= 3.2 Configure login method:[root@mail /]# cat /etc/sasl2/smtpd.conf pwcheck_method: saslauthd mech_list: PLAIN LOGIN log_level:3 4 Start the service:systemctl restart dovecot systemctl restart postfix systemctl restart saslauthd systemctl enable dovecot systemctl enable postfix systemctl enable saslauthd 5 Create a user and set a pass[root@mail /]# useradd -m autumn && echo 123456 | passwd --stdin autumn [root@mail /]# su - autumn [autumn@mail ~]$ mkdir -p ~/mail/.imap/INBOX [autumn@mail ~]$ chmod -R 750 ~/mail #(If you do not do this, you will get an error {Error: Couldn't open INBOX: Permission denied} when logging in with foxmail) [autumn@mail ~]$ exit 6 Configure mailx:[root@mail /]# cat /etc/mail.rc set [email protected] set smtp=mail.liqing-test.top set smtp-auth-user=autumn set smtp-auth-password=123456 set smtp-auth=login 4. Send email test1 Command line email sending test[root@mail /]# echo "Mail server test" | mail -s "Mail server test" [email protected] 2 Use foxmail to log in and send email testFive Error Reports1 Permission deniedWhen using foxmail to log in to the mailbox, it prompts that permission is denied. This is because the mail file permission in the mailbox user's home directory is not 750. Set it to 750 to solve the problem. [autumn@mail ~]$ chmod -R 750 ~/mail
2 Unable to find host:When sending an email, the mx record will be searched based on the resolution record of the email address. Here, when I sent a test email to Tencent's corporate mailbox, I couldn't find Tencent's email address. I solved it by adding Tencent's mx record to the intranet dns proxy [root@dns- ~]# grep qq /etc/dnsmasq.conf mx-host=***.com,mxbiz2.qq.com,10 mx-host=***.com,mxbiz1.qq.com,5
3 Email rejectedWhen I sent a test email to Tencent's corporate mailbox, the log showed 550 email connection rejected. This problem was solved after setting up a whitelist in the email.
This is the end of this article about the detailed steps of setting up an independent mail server on Centos7.9. For more information about setting up a mail server on Centos, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Detailed explanation of basic concepts of HTML
>>: Detailed explanation of the steps to build a Vue project with Vue-cli
1. Environment and preparation 1. Ubuntu 14.04 2....
In this system, the # sign represents the root us...
Table of contents 1. Container service update and...
1. Syntax TIMESTAMPDIFF(unit,begin,end); Returns ...
1 Installation Download the corresponding unzippe...
In js, set the user to read a certain agreement b...
An optimization solution when a single MYSQL serv...
<body> <div id="root"> <...
If your computer is a Mac, using homebrew to inst...
Table of contents 1. Download the virtual machine...
Web page WB.ExecWB control printing method Copy c...
Interviewer: Have you read the source code of Vue...
Table of contents What happened? When to use Cont...
Table of contents text 1. Prepare the machine 2. ...
In the previous article, we introduced the MySQL ...