Index

7.2 Startup Mail Server virtual machine

7.4 Configure Firewall for Mail service


7.3 Configure Mail Server


• Startup the "Mail" virtual machine (see 7.2 Startup Mail Server virtual machine)




Now you could log in directly in the virtual machine as user root, but connecting through SSH from your host PC, makes it possible to copy and paste text into the console window


• Open "Command Prompt" on your host computer




Write what is highlighted in red


Instead of writing "teddy", then write the username you have created on the master virtual machine:

C:\Users\teddy>ssh teddy@192.168.0.128

teddy@192.168.0.128's password:write your user's password here


[teddy@localhost ~]$ su

Password:write the root password here


Set the hostname of this machine, but use your own domain name instead of "yddet.dk":

[root@localhost teddy]# hostnamectl set-hostname mail.yddet.dk


Backup and edit the postfix configuration file:

[root@localhost teddy]# cd /etc/postfix

[root@localhost postfix]# cp main.cf /backup

[root@localhost postfix]# vim main.cf


Add the lines highlighted in red, but use your own domain name instead of "yddet.dk":

#myhostname = host.domain.tld

#myhostname = virtual.domain.tld

myhostname = mail.yddet.dk


#mydomain = domain.tld

mydomain = yddet.dk


Remove the comment mark from the line highlighted in red:

#myorigin = $myhostname

myorigin = $mydomain


Remove the comment mark from the first line highlighted in red, and add a comment mark to the last of these lines:

#inet_interfaces = all

inet_interfaces = $myhostname

#inet_interfaces = $myhostname, localhost

#inet_interfaces = localhost


Add a comment mark to the first of these lines, and remove the comment mark from the line highlighted in red:

#mydestination = $myhostname, localhost.$mydomain, localhost

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,

# mail.$mydomain, www.$mydomain, ftp.$mydomain


Add the lines highlighted in red:

#mynetworks = 168.100.189.0/28, 127.0.0.0/8

#mynetworks = $config_directory/mynetworks

#mynetworks = hash:/etc/postfix/network_table

mynetworks = 192.168.255.0/24, 192.168.1.0/24, 192.168.0.0/24, 127.0.0.0/8


#relay_domains = $mydestination

relay_domains =


#home_mailbox = Mailbox

#home_mailbox = Maildir/

home_mailbox = mail/


Save the document and quit vim


Install the IMAP and POP3 service:

[root@localhost postfix]# yum install dovecot -y

output output output ...

Complete!


Backup and edit the dovecot configuration file:

[root@localhost postfix]# cd /etc/dovecot

[root@localhost dovecot]# cp dovecot.conf /backup

[root@localhost dovecot]# vim dovecot.conf


To set the location of the user mail directory, add these lines to the end of the document:

# Location of mail directory

mail_location = maildir:~/mail


Save the document and quit vim


Backup and edit the authentication configuration file:

[root@localhost dovecot]# cd conf.d

[root@localhost conf.d]# cp 10-auth.conf /backup

[root@localhost conf.d]# vim 10-auth.conf


To enable insecure plain text login, find this line and remove the comment mark and change it to:

disable_plaintext_auth = no


Save the document and quit vim


Backup and edit the ssl configuration file:

[root@localhost conf.d]# cp 10-ssl.conf /backup

[root@localhost conf.d]# vim 10-ssl.conf


To enable both plain and secure mail protocols, find this line and change it to:

ssl = yes


Save the document and quit vim


[root@localhost conf.d]# cp 10-logging.conf /backup

[root@localhost conf.d]# vim 10-logging.conf


To make dovcot log information to a file, add the line highlighted in red:

#log_path = syslog

log_path = /var/log/dovecot.log


Save the document and quit vim


Enable the IMAP and POP3 service at system startup:

[root@localhost conf.d]# systemctl enable dovecot

Created symlink from /etc/systemd/system/multi-user.target.wants/dovecot.service to /usr/lib/systemd/system/dovecot.service.


Edit the configuration file for the first Ethernet adapter:

[root@localhost conf.d]# EditNet


Find these lines and change them to:

IPADDR=192.168.255.4

GATEWAY=192.168.255.1

DNS1=192.168.255.2


Add this line to the end of the document, but use your own domain name instead of "yddet.dk":

DOMAIN=yddet.dk


Save the document and quit vim


Shutdown the system, and exit "Command Prompt":

[root@localhost conf.d]# shutdown -h now

Connection to 192.168.0.128 closed by remote host.

Connection to 192.168.0.128 closed.


C:\Users\teddy>exit


• Return to the "Mail" virtual machine



Click "X" to close the virtual machine

Return to "Hyper-V Manager"



At "Actions" click "Settings..."



At "Hardware" select "Network Adapter"

• At "Virtual switch:" select "DMZ"

• Click "OK"