Most of programs will not accept an email using just @localhost as domain.
So, edit /etc/hosts
file to make the domain localhost.com point to your machine by adding this line to the file:
127.0.0.1 localhost.com
To make the change, open the /etc/hosts file using nano or your favorite text editor.