Install sendmail

apt-get install sendmail

To verify: ps -aux | grep sendmail

Fix your hosts

Verify your hostname: hostname

Edit your hosts file: nano /etc/hosts

Adjust this line similarly:

127.0.0.1 host.example.com yourhostname localhost.localdomain localhost

Configure sendmail

Modify your config file and add your domain.

sudo nano /etc/mail/sendmail.mc

and add these two lines at the bottom (replace with your domain name):

define(`MAIL_HUB', `example.com.')dnl
define(`LOCAL_RELAY', `example.com.')dnl

Run sendmail config and choose Y when prompted.

Restart sendmail with: service sendmail restart

Test your setup

echo -e "To: user@example.com\nSubject: Test\nTest\n" | sendmail -bm -t -v