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.

Installation
Log in as root (
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
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:
sudo sendmailconfig


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.
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
- 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
- Where to check
- How to configure a real domain name for
- How to stop and restart
- Install and configure Sendmail on Ubuntu
- How do I find out what mail program is installed/sending emails?
How to install and configure Sendmail on Ubuntu
Install Sendmail on your Ubuntu server in couple minutes
Sendmail Ubuntu Linux