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 an independent mail server by Centos7.9

2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Editor to share with you how to build Centos7.9 independent mail server, I hope you will learn something after reading this article, let's discuss it together!

A configuration intranet dns A record and MX record the domain name host used in my intranet is dnsmasq agent software, which is simple, convenient and diversified. Additional documentation can be viewed for detailed configuration.

[root@dns_proxy ~] # grep liqing / etc/dnsmasq.confaddress=/mail.liqing-test.top/192.168.2.100mx-host=liqing-test.top,mail.liqing-test.top,10 two mail server initialization configuration 1. Modify the hostname [root@localhost /] # hostnamectl-- static set-hostname mail.liqing-test.top | bash2. Turn off the firewall and selinux [root@mail /] # systemctl stop iptables & & systemctl disable iptables [root@mail /] # systemctl stop firewalld & & systemctl disable firewalld [root@mail /] # setenforce 03. Enable time synchronization [root@mail /] # yum-y install ntpdate & & ntpdate ntp.aliyun.com4. Installation software [root@mail /] # yum-y install postfix dovecot cyrus-sasl-* mailx three modify configuration file Notes: configuration file backup operation this document operates on its own

1 configure postfix [root@mail /] # cat / etc/postfix/main.cfmail_owner = postfixmyhostname = mail.liqing-test.topmydomain = liqing-test.topmyorigin = $mydomaininet_interfaces = allinet_protocols = ipv4mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain, www.$mydomain Ftp.$mydomainlocal_recipient_maps = mynetworks = 0.0.0.0/0relay_domains = $mydestinationalias_maps = hash:/etc/aliasesalias_database = hash:/etc/aliasessmtpd_banner = $myhostname ESMTP# add smtpd_sasl_type = dovecotsmtpd_sasl_path = private/authsmtpd_sasl_local_domain = smtpd_sasl_auth_enable = yessmtpd_sasl_security_options = noanonymousbroken_sasl_auth_clients = yessmtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination at the bottom Permit_sasl_authenticatedsmtpd_client_restrictions = permit_sasl_authenticated2 configuration dovecot2.1 configuration listening protocol: [root@mail /] # cat / etc/dovecot/dovecot.confprotocols = imap pop3 lmtplisten = * login_trusted_networks = 0.0.0.0/0dict {}! include conf.ddeband login method: [root@mail /] # cat / etc/dovecot/conf.d/10-auth.confdisable_plaintext_auth = noauth_ Mechanisms = plain logins include auth-system.conf.ext2.3 configuration message storage location: [root@mail /] # cat / etc/dovecot/conf.d/10-mail.confmail_location = mbox:~/mail:INBOX=/var/mail/%unamespace inbox {inbox = yes} first_valid_uid = 1000mbox_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 configuration ssl (off): [root@mail /] # cat / etc/dovecot/conf.d/10-ssl.conf ssl = no3 configuration sasl23.1 configuration system authentication: [root@mail /] # cat / etc/sysconfig/saslauthd SOCKETDIR=/run/saslauthdMECH=shadowFLAGS=3.2 configuration login method: [root@mail /] # cat / etc/sasl2/smtpd.confpwcheck_method: saslauthdmech_list: PLAIN LOGINlog_level 34 start the service: systemctl restart dovecotsystemctl restart postfixsystemctl restart saslauthdsystemctl enable dovecotsystemctl enable postfixsystemctl enable saslauthd5 creates a user and sets 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 don't do this, you will log in to the Times {Error: Couldn't open INBOX: Permission denied}) [autumn@mail ~] $exit6 configuration mailx: [root@mail /] # cat / etc/mail.rcset from=autumn@liqing-test.topset smtp=mail.liqing-test.topset smtp-auth-user=autumnset smtp-auth-password=123456set smtp-auth=login four send mail test 1 command line send mail test [root@mail /] # echo "mail server test" | mail-s "mail server test" other-email@163.com2 makes Test by logging in and sending email using foxmail

Five error report 1 permission denied when using foxmail to log in to the mailbox, this is because the mail file permission under the mailbox user's home directory is not 750. it is solved when it is set to 750.

[autumn@mail] $chmod-R 750 ~ / mailDec 3 10:15:35 Git-server dovecot: pop3-login: Login: user=, method=PLAIN, rip=192.168.31.100, lip=192.168.2.100, mpid=24843, secured, session=

Dec 3 10:15:35 Git-server dovecot: pop3 (autumn): Error: fchown (/ home/autumn/mail/.imap, group=12 (mail)) failed: Operation not permitted (egid=1004 (autumn), group based on / var/mail/autumn-see http://wiki2.dovecot.org/Errors/ChgrpNoPerm)

Dec 3 10:15:35 Git-server dovecot: pop3 (autumn): Error: Couldn't open INBOX: Permission denied

Dec 3 10:15:35 Git-server dovecot: pop3 (autumn): Couldn't open INBOX: Permission denied top=0/0, retr=0/0, del=0/0, size=0

Dec 3 10:16:26 Git-server dovecot: pop3-login: Login: user=, method=PLAIN, rip=192.168.31.100, lip=192.168.2.100, mpid=24895, secured, session=

Dec 3 10:16:26 Git-server dovecot: pop3 (autumn): Error: fchown (/ home/autumn/mail/.imap, group=12 (mail)) failed: Operation not permitted (egid=1004 (autumn), group based on / var/mail/autumn-see http://wiki2.dovecot.org/Errors/ChgrpNoPerm)

2 unable to find the host: when sending the email, it will look up the mx record according to the resolution record of the email address. Here, I cannot find the Tencent email address when I send the test email to Tencent's enterprise mailbox. I added Tencent's mx record to the dns agent of the intranet to solve the problem.

[root@dns- ~] # grep qq / etc/dnsmasq.conf mx-host=***.com,mxbiz2.qq.com,10mx-host=***.com,mxbiz1.qq.com,5Dec 3 10:36:14 Git-server postfix/smtpd [26216]: connect from unknown [192.168.31.100]

Dec 3 10:36:15 Git-server postfix/smtpd [26216]: 05C682267F04: client=unknown [192.168.31.100], sasl_method=LOGIN, sasl_username=autumn

Dec 3 10:36:15 Git-server postfix/cleanup [26220]: 05C682267F04: message-id=

Dec 3 10:36:15 Git-server postfix/qmgr [25430]: 05C682267F04: from=, size=1561, nrcpt=1 (queue active)

Dec 3 10:36:15 Git-server postfix/smtpd [26216]: disconnect from unknown [192.168.31.100]

Dec 3 10:36:15 Git-server postfix/smtp [26221]: 05C682267F04: to=, relay=none, delay=0.11, delays=0.08/0.02/0/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=***.com type=MX: Host not found, try again)

3 email rejected 550 email connection was rejected in the log when I sent a test email to Tencent enterprise mailbox. This situation can be solved after setting up a whitelist in the email.

Dec 3 10:11:57 Git-server postfix/smtpd [24617]: connect from mail.liqing-test.top [192.168.2.100]

Dec 3 10:11:57 Git-server postfix/smtpd [24617]: 4E2292267F04: client=mail.liqing-test.top [192.168.2.100], sasl_method=LOGIN, sasl_username=autumn

Dec 3 10:11:57 Git-server postfix/cleanup [24621]: 4E2292267F04: message-id=

Dec 3 10:11:57 Git-server postfix/qmgr [24504]: 4E2292267F04: from=, size=541, nrcpt=1 (queue active)

Dec 3 10:11:57 Git-server postfix/smtpd [24617]: disconnect from mail.liqing-test.top [192.168.2.100]

Dec 3 10:11:58 Git-server postfix/smtp [24622]: 4E2292267F04: to=, relay=mxbiz1.qq.com [183.57.48.34]: 25, delay=1.6, delays=0.09/0.03/0.16/1.3, dsn=5.0.0, status=bounced (host mxbiz1.qq.com [183.57.48.34] said: 550Mail content denied. Http://service.exmail.qq.com/cgi-bin/help?subtype=1&&id=20022&&no=1000726 (in reply to end of DATA command))

After reading this article, I believe you have a certain understanding of "how to build an independent mail server in Centos7.9". If you 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

Development

Wechat

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

12
Report