Updating hostname in postfix involves updating several files. First, we need to update the following file with the new hostname:
So, we can use the following command to update the file with nano editor
Then, we’ll need to update the postfix configuration file that’s located at /etc/postfix/main.cf . In the file, we’ll update the hostname with the new hostname. So, the new hostname line should be
myhostname = newhost.yourdomain.com
Then, we need to restart postfix service with the following command –
sudo service postfix restart
Done! Your new hostname should appear in your mail now.