Configure sending mail by sendmail in Ubuntu Linux


I need email functionality to send emails from the web server by querying data from MySQL database and email the result to appropriate recipient.


  1.  Install sendmail.
    • sudo apt-get update
    • sudo apt-get install sendmail
  1. Install mailutils.
    • sudo apt-get install mailutils
  2. Configure the /etc/hosts file, provide your domain name in the following format
    • localhost yourhostname
  3. Configure the sendmail, provide Yes to all when prompt.
    • sudo sendmailconfig
  4. Find the sendmail path.
    • which sendmail
  5. Locate the php.ini file.
    • locate php.ini
  6. Open the php.ini file and provide the result of the “which sendmail” as entry for sendmail_path variable,if entry already exists uncomment it. For my case “which sendmail” output is /usr/sbin/sendmail.
    • sendmail_path = "env -i /usr/sbin/sendmail -t -i"
  7. Restart Apache server
    • sudo service apache2 restart
  8. Send a test email:
    1. Connect with telnet on port 25
      • telnet 25
    2. Type the following to see the server works
      • helo server
    3. Supply the Sender address
      • MAIL from:
    4. Supply the Recipient address
      • RCPT to:
    5. Provide the email contents and at the end type the dot(.) in anew line to send email.
      • Subject: Test email
      • This is a test email from sendmail.
      • .
    6. Check to see the email arrived, if not found in inbox search it in junk folder.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.