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 block

Installation

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.

Configuration

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):

127.0.0.1 your-site.com
127.0.0.1 localhost.localdomain localhost your-server.com

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

127.0.0.1    localhost hostname
127.0.1.1    hostname

Run Sendmail config and answer Y for everything:

sudosendmailconfig
                
Odoo text and image block
Odoo image and text block

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

Done

Test if Sendmail is working

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

echo "test message" | sendmail -v your@email.com

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 block

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 mails 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 a 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?

- Sendmail.org