How to Install And Configure Sendmail on Ubuntu

1. Install Sendmail:

$ sudo apt-get install sendmail

2. Configure /etc/hosts file:

Run:

$ hostname

To find your hostname

Then copy the same hostname, and run:

$ sudo nano /etc/hosts

How to Install Sendmail in Ubuntu

On the second line starting with 127.0.0.1, add the hostname to the end so it looks like the same as:

127.0.0.1 localhost your_hostname_here

(You will notice that your hostname can also be identified on the line that starts with 127.0.1.1 where it appears twice).

Then Press CTRl+X, then type ‘Y’ and press ENTER to save changes.

3. Run Sendmail’s config and answer ‘Y’ (May be three times it will ask for input):

$ sudo sendmailconfig

4. Restart Your Apache Service:

$ sudo service apache2 restart

5. Now You Can Start Using Sendmail:

$ sendmail -v receiver@mail.com

Press ENTER

From: sender@mail.com

Press ENTER

Subject: Email Subject Here

Press ENTER

Here type your message...

Press ENTER

.

Press ENTER

How to Configure Sendmail In Ubuntu

Wait for sometime till then you will see the output of your email has been sent.

6. Troubleshoot:

If for some reason, you’re receiver doesn’t receives the email. Here are the steps you can follow to troubleshoot the reason.

$ sudo nano /etc/php/7.0/fpm/php.ini

Press Ctrl+W to search for and find ‘sendmail_path’. Uncomment this line and add the path below:

sendmail_path= /usr/sbin/sendmail -t -i

Then Press CTRl+X, then type ‘Y’ and press ENTER to save changes.

After that, Restart PHP Service:

$ sudo service php7.0-fpm restart

About the author

Technical Sahil

Sahil Dhamija is a visionary entrepreneur and tech enthusiast, proudly owning multiple companies across India, the US, the UK, and the UAE. As the founder of AInventions Technologies LLC, DigitalMarkethink Solutions LLC, WebReinvent Technologies LLC, BusinessMate Software Solutions LLC, and co-founder of Hostyaga FZE LLC, Sahil is a dynamic leader shaping the future of technology and digital marketing.

Apart from leading his businesses, Sahil is a passionate tech YouTuber, sharing insights and tutorials on various technological topics. He also serves as the CTO at Vayuna Corporate Travels Pvt Ltd and as Product Head at Vayuna Voicetech Pvt Ltd, where he oversees cutting-edge solutions in corporate travel and voice technology. Additionally, Sahil is a creative force in the film industry, producing films through Gentle Breeze Films Pvt Ltd.

Driven by innovation and creativity, Sahil continues to push boundaries in technology, media, and business.

View all posts

8 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *