Sendmail is the most popular UNIX-based implementation of the Simple Mail Transfer Protocol (SMTP) for transmitting e-mail.
This tutorial its for Debian 8 but should work for latest Debian and Ubuntu versions as well.
STEP 1: Configure hosts file correctly:
And make sure the line looks like this:
STEP 2: Edit etc/mail/local-host-names (create it if doesn't exist).
localhost
yourhostname.localhost
STEP 3: Reload /etc/hosts, so that the previous changes take effect:
(WARNING: The next command may make your server reboot)
Or reboot from server panel
STEP 4: Run the sendmail config and answer (Y) to everything:
(Now you can test if sendmail its working:)
STEP 5: Add this command in /etc/mail/sendmail.mc after line MAILER_DEFINITIONS:
define(`confDOMAIN_NAME', `your.domain')dnl