linux open source mailbox server building

1. Install Postfix

yum -y install postfix

After installation, you need to replace the sendmail that comes with the system:

rpm -e sendmail perhaps yum remove sendmail

Modify MTA (default mail transfer agent)

alternatives --config mta and enter directly.

2. Install Dovecot (post office forwarding)

yum -y install dovecot

3. configure Postfix

vi /etc/postfix/main.cf

Amend to read:

75 That's ok: Uncomment, setting hostname 
myhostname = mail.linkdood.cn
 # Line 83: uncomment, set domain name 
mydomain = linkdood.cn 
# Line 99: uncomment 
myorigin = $mydomain
 # Line 116: modify 
inet_interfaces = all
 # Line 119: ipv4 is recommended. If ipv6 is supported, it can be all 
inet_protocols = ipv4 
# 164 lines: adding 
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain 
# Line 264: uncomment, specify the IP address range of Intranet and local 
#mynetworks = 127.0.0.0/8, 10.0.0.0/24
 Mynetworks = 0.0.0.0/0 
# Line 419: uncomment, mail save directory 
home_mailbox = Maildir/ 
# Line 571: add 
smtpd_banner = $myhostname ESMTP 
# Add to last # The maximum size of the specified mail is 10M (use the default value according to the actual situation or not) 
message_size_limit = 10485760
# The maximum capacity of inbox is 1G 
mailbox_size_limit = 1073741824 
# SMTP authentication  
smtpd_sasl_type = dovecot 
smtpd_sasl_path = private/auth 
smtpd_sasl_auth_enable = yes 
smtpd_sasl_security_options = noanonymous 
smtpd_sasl_local_domain = $myhostname 
smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject

Use after modification

/etc/init.d/postfix restart

Start postfix

chkconfig  postfix on

4. Configure Dovecot

[root@mail ~]# vi /etc/dovecot/dovecot.conf 
# Line 26: if IPv6 is not used, change to* 
listen = * [root@mail ~]
# vi /etc/dovecot/conf.d/10-auth.conf
 # Line 9: uncomment and modify 
disable_plaintext_auth = no 
# 97 lines: add 
auth_mechanisms = plain login 
[root@mail ~]# vi /etc/dovecot/conf.d/10-mail.conf 
# Line 30: uncomment and add 
mail_location = maildir:~/Maildir [root@mail ~]
# vi /etc/dovecot/conf.d/10-master.conf 
# Lines 88-90: uncomment and add 
# Postfix smtp authentication 
unix_listener /var/spool/postfix/private/auth { 
mode = 0666
user = postfix
group = postfix 
} 
[root@mail ~]# /etc/init.d/dovecot start 
Starting Dovecot Imap: [ OK ] 
[root@mail ~]# chkconfig dovecot on

So far, our email server has been built successfully.

5. Domain name resolution
Finally, don't forget that domain name resolution is still needed.
Add A sub domain name mail, A record resolves to server IP.
Add another MX record. The host record is empty and the record value is the secondary domain name resolved above mail.linkdood.cn , priority 10.
Note: resolution may take some time to take effect.
6. Firewall settings

/sbin/iptables  -A INPUT -p tcp  --dport 25   -j ACCEPT
/sbin/iptables  -A INPUT -p tcp  --dport 110  -j ACCEPT
/sbin/iptables  -A INPUT -p tcp  --dport 143  -j ACCEPT
/sbin/iptables -t nat -A PREROUTING  -p tcp  -m tcp --dport 10025  -j REDIRECT  --to-ports 25

7. Use of mailbox
After everything is done, you can use third-party software such as Foxmail to send and receive emails. It needs to be said here that the system user is the mail user, for example, root is a mailbox user, and the mailbox is root@domain.com , the password is root's password, so you need to create a user. Just use useradd to create a user, and then use passwd to set the password.
OK, if you create an admin user:

# Create user 
useradd admin 
#To set the password, you will be required to enter the password twice 
passwd admin

Keywords: iptables yum RPM firewall

Added by bongbong on Wed, 20 May 2020 18:04:50 +0300