Configure Postfix on Ubuntu 16.04 as SMTP

If the postfix has been installed, then run the following command to reconfigure

sudo dpkg-reconfigure postfix

Answer the question as the following:

  • General type of mail configuration: Internet Site
  • System mail name: Can be any domain, even a fake one.
  • Root and postmaster mail recipient: ubuntu the login user in ubuntu system that you have created
  • Other destinations to accept mail for (blank for none): $myhostname,, localhost.localdomain, , localhost
  • Force synchronous updates on mail queue? No
  • Local networks: [::ffff:]/104 [::1]/128
  • Use procmail for local delivery? Yes
  • Mailbox size limit (bytes): 0
  • Local address extension character: +
  • Internet protocols to use: all

Edit the postfix config file to point to virtual file:
vi /etc/postfix/
Set this value
virtual_alias_maps = hash:/etc/postfix/virtual

Edit the virtual addresses with the following command:

sudo vi /etc/postfix/virtual

Add the following entries: ubuntu ubuntu

Then run the following command:
postmap /etc/postfix/virtual

Lastly restart postfix.

To debug and find out what happen when you send mail with this command
echo "Test mail" | mail -s "Test"

tail -f /var/log/mail.log
tail -f /var/log/mail.err


Set root password for mysql on Ubuntu LTS 16.04.3

After a manual installation of mysql using apt-get install (instead of install it during ubuntu installation), to set the root password for mysql on Ubuntu LTS 16.04.3, follow the steps below:

sudo mysql 

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'hard to guess password'; 
Query OK, 0 rows affected (0.01 sec) 

mysql> flush privileges; 
Query OK, 0 rows affected (0.01 sec) 

mysql> exit 

Please replace ‘hard to guess password’ with your own password.