Installing Mail SMTP server on Ubuntu

In this post I'll describe, how to install SMTP server.
Install mailutils:
sudo apt-get install mailutils
Select   Internet Site. Change  System mail name, if needed. In my case it will be
After installation, try to send test email to your Gmail box with command
echo "This is the body of the email" | mail -s "This is the subject line" [email protected]
It should be received Gmail like Spam - check your Spam folder and you will see email "This is the subject line". It will be labeled as " security: No encryption Learn more".
Let's setup encryption.
Install letsencrypt to generate certificates:
sudo apt install letsencrypt
Once the install is finished, you can run the certificate process with the easy command below. Replace the with your domain name.
sudo letsencrypt certonly --standalone -d
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]

Please read the Terms of Service at You must agree
in order to register with the ACME server at
(A)gree/(C)ancel: A

Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about EFF and
our work to encrypt the web, protect its users and defend digital rights.
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
tls-sni-01 challenge for
Waiting for verification...
Cleaning up challenges

 - Congratulations! Your certificate and chain have been saved at:
   Your key file has been saved at:
   Your cert will expire on 2018-01-05. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot
   again. To non-interactively renew *all* of your certificates, run
   "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:
   Donating to EFF:          

Configure Postfix to use your certificates:
sudo postconf -e 'smtpd_tls_cert_file = /etc/letsencrypt/live/'
sudo postconf -e 'smtpd_tls_key_file = /etc/letsencrypt/live/'
Then configure Postfix to provide TLS encryption for both incoming and outgoing mail.
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 systemctl restart postfix
After all of this ask your hosting provider to add Reverse DNS, by providing them your hosting FQDN and IP. For example:
Please, add Reverse DNS for my servers IP and FQDN
After your hosting provider will make all needed changes for that, you can check it with or with or with any other tools, that you Google by phrase  reverse dns lookup.