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 [email protected]

Press ENTER

From: [email protected]

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

Hello I’m Sahil, May be most of you guys know me as Technical Sahil on YouTube. Founder of Hostrigger & Mailracle and running several other things online.

View all posts

8 Comments

Leave a Reply

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