Install Postfix mail server

 

Log in as root

 

open terminal and check if the hash symbol is there.

 

If so, then you are root and you don't have to type sudo first

 

root@vps#

 

apt update

 

apt upgrade

 

 

Postfix & Dovecot:

 

dig mx checktls.nl

apt install postfix

Choose Internet site and provide mail server domain name. In this case checktls.nl

apt install mailutils

Create a user for info@checktls.nl

useradd -m -s /bin/bash info

And give user info a password:

passwd info

Check if everything works:

postfix status

telnet localhost 25

quit

 

Test sending an internal email from root to info

telnet localhost 25

ehlo localhost

mail from: root@localhost

rcpt to: info@localhost

data

Subject: My first mail on Postfix

 

Hi,

Are you there?

regards,

Admin

. (Type the .[dot] in a new Line and press Enter )

quit

 

Check if the email arrived:

su - info

mail

 

 

Back to root:

su - root (password)

postconf -e "home_mailbox = Maildir/"

postconf -e "mailbox_command = "

/etc/init.d/postfix restart

 

su - info

MAIL=/home/info/Maildir

mail

 

apt install courier-pop

apt install courier-imap

postconf -e "mydestination = mail.checktls.nl, localhost.localdomain, localhost, checktls.nl"

postconf -e "inet_interfaces = all"

postconf -e "inet_protocols = all"

service courier-authdaemon start

systemctl enable courier-authdaemon

/etc/init.d/postfix restart

 

netcat mail.checktls.nl 25

 

ehlo checktls.nl

mail from: root@checktls.nl

rcpt to: info@checktls.nl

data

Subject: My first mail for my domain

 

Hi,

Are you there?

regards,

Admin

. (and Enter In a new Line)

quit

 

su - info

cd Maildir/new

ls

 

netcat mail.checktls.nl 110

user info

+OK Password required.

pass password

+OK logged in.

quit

 

certbot certonly --standalone -d mail.checktls.nl

postconf -e 'smtpd_tls_cert_file = /etc/letsencrypt/live/mail.checktls.nl/fullchain.pem'

postconf -e 'smtpd_tls_key_file = /etc/letsencrypt/live/mail.checktls.nl/privkey.pem'

 

postconf -e 'smtpd_sasl_type = dovecot'

postconf -e 'smtpd_sasl_path = private/auth'

postconf -e 'smtpd_sasl_local_domain ='

postconf -e 'smtpd_sasl_security_options = noanonymous'

postconf -e 'broken_sasl_auth_clients = yes'

postconf -e 'smtpd_sasl_auth_enable = yes'

postconf -e 'smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'

 

sudo postconf -e 'smtp_tls_security_level = may'

sudo postconf -e 'smtpd_tls_security_level = may'

sudo postconf -e 'smtp_tls_note_starttls_offer = yes'

sudo postconf -e 'smtpd_tls_loglevel = 1'

sudo postconf -e 'smtpd_tls_received_header = yes'

 

sudo postconf -e 'virtual_alias_domains = $mydomain'

sudo postconf -e 'virtual_alias_maps = hash:/etc/postfix/virtual'

 

sudo nano /etc/postfix/virtual

 

postmaster@checktls.nl root

root@checktls.nl root

info@checktls.nl info

bas@checktls.nl bas

 

sudo postmap /etc/postfix/virtual

sudo systemctl restart postfix

 

sudo apt install dovecot-imapd dovecot-pop3d

 

sudo maildirmake.dovecot /etc/skel/Maildir

sudo maildirmake.dovecot /etc/skel/Maildir/.Drafts

sudo maildirmake.dovecot /etc/skel/Maildir/.Sent

sudo maildirmake.dovecot /etc/skel/Maildir/.Trash

sudo maildirmake.dovecot /etc/skel/Maildir/.Templates

 

sudo adduser bas sudo

 

sudo cp -r /etc/skel/Maildir /home/$USER/

sudo chown -R $USER:$USER /home/$USER/Maildir

sudo chmod -R 700 /home/$USER/Maildir

sudo adduser $USER mail

 

as root (has no homedir)

 

sudo cp -r /etc/skel/Maildir /$USER/

sudo chown -R $USER:$USER /$USER/Maildir

sudo chmod -R 700 /$USER/Maildir

sudo adduser $USER mail

 

echo 'export MAIL=~/Maildir' | sudo tee -a /etc/bash.bashrc | sudo tee -a /etc/profile.d/mail.sh

 

sudo nano /etc/dovecot/conf.d/10-auth.conf

 

disable_plaintext_auth = yes

auth_mechanisms = plain login

 

sudo nano /etc/dovecot/conf.d/10-mail.conf

 

mail_location = maildir:~/Maildir

 

 

sudo nano /etc/dovecot/conf.d/10-master.conf

 

 

service imap-login {

inet_listener imap {

port = 143

}

}

service pop3-login {

inet_listener pop3 {

port = 110

}

...

}

...

service auth {

...

# Postfix smtp-auth

unix_listener /var/spool/postfix/private/auth {

mode = 0660

user = postfix

group = postfix

}

 

 

sudo nano /etc/dovecot/conf.d/10-ssl.conf

 

# SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>

ssl = required

...

ssl_cert = </etc/letsencrypt/live/mail.checktls/fullchain.pem

ssl_key = </etc/letsencrypt/live/mail.checktls/privkey.pem

...

# SSL protocols to use

ssl_protocols = !SSLv2 !SSLv3

 

sudo nano etc/postfix/main.cf

 

# No Client initiated renegotiation

tls_ssl_options = NO_RENEGOTIATION

 

dovecot -n

sudo systemctl restart dovecot

 

nc mail.checktls.nl 25

EHLO $hostname

MAIL FROM:<root@checktls.nl>

RCPT TO:<info@checktls.nl>

DATA

Subject: Test email

 

Tessie

.

QUIT

 



    Last modified 01/01/2026
User
🇳🇱