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: test.com 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, test.com, localhost.localdomain, , localhost
  • Force synchronous updates on mail queue? No
  • Local networks: 127.0.0.0/8 [::ffff:127.0.0.0]/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/main.cf
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:

contact@test.com ubuntu
admin@test.com 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" ltest@yahoo.com

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

Advertisements

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 
Bye

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