How to fix error “host NAME greeted me with my own hostname NAME”

I noticed once on one server that Postfix does not always send mail, the logs had the following error:

warning: host NAME[192.168.5.5]:25 greeted me with my own hostname NAME

After seeing the host name:

hostname -f

Found that it is not correct and coincides with that on which the mail is sent!

Changed the host name to the correct one in the following files (in the nano editor Ctrl+X to exit, y/n to save or cancel changes):

sudo nano /etc/hostname
sudo nano /etc/postfix/main.cf
sudo nano /etc/hosts

Done, after that the error did not appear and the mail was successfully delivered.