Bobcares

DigitalOcean Sendmail | How To Setup?

by | Nov 28, 2022

Let’s take a closer look at configuring Sendmail on DigitalOcean Server. At Bobcares, with our DigitalOcean Managed Service, we can handle your DigitalOcean Sendmail issues.

DigitalOcean Sendmail

Sending emails is one of the most frequent requirements when configuring a new web server. Connecting the server to a mailing service is the safest and simplest way to achieve this. By using an external service, we can avoid problems like the server’s IP address being added to a blacklist by anti-spam programs.

Sendmail is a general-purpose internetwork email routing tool that supports a wide range of mail transfer and delivery techniques, therefore integrating it with DigitalOcean gives numerous benefits to customers. It’s an excellent lightweight MTA that delivers emails from shell scripts, PHP apps, or even the command line. It also negotiates STARTTLS for encrypted email transmission if the remote SMTP server supports it, which is a good security practice.

How to set up Sendmail on DigitalOcean servers?

In this section, we’ll see the steps provided by our Support team to install and configure Sendmail on Ubuntu.

  1. Firstly, install Sendmail using the command:
    $ sudo apt-get install sendmail

     

  2. Now configure /etc/hosts file. To find the hostname, use the command:
    $ hostname

     

  3. Then type the command:
    $ sudo nano /etc/hosts

     

  4. On the line starting with 127.0.0.1, add the hostname to the end so it looks the same as:
    127.0.0.1 localhost hostname

     

  5. Now press Ctrl+x, then ‘Y’ to save and exit.
  6. Run Sendmail’s config and answer ‘Y’ to everything.
    $ sudo sendmailconfig

     

  7. Now restart Apache with the command:
    $ sudo service apache2 restart

     

  8. To send an email using Sendmail, use the command:
    $ sendmail -v someone@email.com

     

  9. After pressing the enter key, insert a From address on the line right below.
    From: you@yourdomain.com

     

  10. Hit enter again and type a subject.
    Subject: This is the subject field of the email

     

  11. To type the message, press Enter again.
    This is the message to be sent.

     

  12. Hit enter again. Finally, to send the email, type a ‘.‘ on the empty line and press enter.

Now we have to wait for a few seconds and we will see the output of the email being sent.

How to fix the error that occurs while using Sendmail on DigitalOcean?

When sending emails from the server, make sure to check any spam folders for receipt. If the email is for some reason not working, try the following steps:

$ 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

Restart php(modify php version as required):

$ sudo service php7.0-fpm restart

[Looking for a solution to another query? We are just a click away.]

Conclusion

This article briefly explains the steps to install and configure Sendmail on DigitalOcean servers setup with Ubuntu OS. It also includes the method to fix some common errors.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.