Mail Server Setup Notes - Oliver-Mustoe/Oliver-Mustoe-Tech-Journal GitHub Wiki
In this page I detail how I setup a CentOS 7 VM as a mail server
Notes
(THIS MAY BE REPEATED, PLEASE EITHER USE SUDO OR BE A ROOT USER WHEN USING NANO)
First I changed the network adapter to LAN, then started the VM and followed the following guide with a few changes:
IP: 10.0.5.4
Hostname: mail01.yourdomain.local
Link to guide: Linux Setup Notes
I then used this guide to setup postfix. (All of the text in the horizontal lines is taken from the guide and modified for exactly this lab)
SOURCE:https://wiki.centos.org/HowTos/postfix
I downloaded dovecot (yum install dovecot) and then nano'd (while either using the sudo command or being root) into /etc/postfix/main.cf with the command nano /etc/postfix/main.cf.
From there I added, edited or uncommented (erase the # at the beginning) the following lines like so:
- myhostname = mail01.firstname.local
- mydomain = firstname.local
- myorigin = $myhostname
- inet_interfaces = all
- mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
- mynetworks = 10.0.5.0/24
- relay_domains = (LEAVE BLANK)
- home_mailbox = Maildir/
After this part of the setup I moved on to this guide to setup Dovecot for POP3 and IMAP. (All of the text in the horizontal lines is taken from the guide and modified for exactly this lab)
SOURCE:https://tecadmin.net/install-dovecot-centos-7/
I configured the following files, in bold, either adding, editing or uncommenting (erase the # at the beginning) the information bulleted:
dovecot.conf (nano /etc/dovecot/dovecot.conf)
- protocols = imap pop3 lmtp
- listen = *, ::
10-mail.conf (nano /etc/dovecot/conf.d/10-mail.conf)
- mail_location = maildir:~/Maildir
10-master.conf (nano /etc/dovecot/conf.d/10-master.conf)
- unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix
}
10-ssl.conf (nano /etc/dovecot/conf.d/10-ssl.conf)
- ssl = yes
- ssl_cert = (BLANK)
I then went back to this guide
SOURCE:https://wiki.centos.org/HowTos/postfix
I then ran the following commands for each user, just the user "oliver" in this case, to create a mailbox in their home directory with appropriate permissions:
With the user oliver:
- mkdir /home/oliver/Maildir
- chown oliver:oliver /home/oliver/Maildir
- chmod -R 700 /home/oliver/Maildir
After this I nano'd into aliases (nano /etc/aliases) and added the following lines so a user, for example "oliver", can access roots mail. As well as setup a few aliases, for example the user oliver:
With the user oliver:
#Person who should get root's mail
root: oliver
#User aliases
omustoe: oliver
o.mustoe: oliver
After this I reloaded the aliases (newaliases), and reloaded postfix (postfix reload). Then I started dovecot (sudo systemctl start dovecot), and reloaded postfix (postfix reload).
I check on status of postfix with the command systemctl status postfix, and I did the same for dovecot, replace postfix with dovecot. After this I setup a A record for mail01.firstname.local, see here Setup Notes, (specifically the forward lookup zone section, name it "mail01") and setup a MX record using this guide
SOURCE:https://www.mustbegeek.com/add-mx-record-in-windows-dns-server/
MAKE A "A" RECORD FIRST I navigated to the zone the rest of my A records are stored via DNS manager and right clicked on the zone > clicked New Mail Exchanger.
On the menu that pops I click Browse... > Navigate to where the A records are shown > select the recently created mail01 > click OK
(If you want a email suffix that is different from the domain, add it into the "Host or child domain" section)