How to install and configure Sendmail on Ubuntu

Install Sendmail on your Ubuntu server in couple minutes

This tutorial will guide you on how to install and configure Sendmail on Ubuntu. It is made the way you can simply copy and paste the necessary commands and setting.

Odoo • Image and Text


Log in as root (sudo su) and prepare your server:

apt-get update && apt-get upgrade

Start with the customer – find out what they want and give it to them.

sudo apt-get install sendmail

Done, as simple as that.


The fastest way is to edit hosts:

nano /etc/hosts

If you have a domain update the top two lines with(to get hostname just type hostname in terminal): localhost.localdomain localhost

If you don't have a domain yet you can use:    localhost hostname    hostname

Run Sendmail config and answer Y for everything:

sudo sendmailconfig
Odoo • Text and Image
Odoo • Image and Text

Apply the settings and start using

If you are using Apache then restart it:

sudo service apache2 restart

If you are using Nginx you will have to restart Nginx as well as fpm:

sudo service nginx restart
service php7.0-fpm restart



Test if Sendmail is working

The best way to do this is by sending the test email:

echo "test message" | sendmail -v

Can't see this in your mailbox? Check the spam folder. If you are not using any domain it is likely that emails will land in the SPAM.

Odoo • Text and Image

Additional stuff and resources

Some basic commands:

sudo /etc/init.d/sendmail restart 
sudo /etc/init.d/sendmail stop
sudo /etc/init.d/sendmail start

Remember to update your DNS(if your emails are landing in the spam):

- go to whoever hosts your domain(GoDaddy, Route53 etc.)

- enter the hosted zone for the domain and add a TXT entry with VALUE: "v=spf1 mx ip4:your.server.ip.address -all"

- this will allow receivers server recognize the email as actually coming from the domain

Useful links:

Install Sendmail mail server on Debian GNU / Linux

How to test sendmail from the shell

Where to check log of sendmail?

How to configure a real domain name for sender address

How to stop and restart sendmail daemon?

Install and configure Sendmail on Ubuntu

How do I find out what mail program is installed/sending emails?