Send E-mail From Localhost on Ubuntu with PHP |

Congrats, You are Subscribed to Receive Updates.

Send E-mail From Localhost on Ubuntu with PHP


Send E-mail with Localhost on Ubuntu with PHP. The Ubuntu Operating Environment is good for web developers. so mainly you require sometime to send email from localhost. Also you might be necessary to check the email features from localhost development time.

Here I have a small tutorial, Which will help you to send email from localhost. you can configure it very well.



Just follow the steps.

  1. Install ssmtp through terminal
sudo apt-get install ssmtp

2.  You have to configure your gmail here to use.  So you have to edit the configuration file. You can edit it by accessing the direct path  or you can go with shell mode.

3. Here I used  my gmail credentials in the:

gksu gedit /etc/ssmtp/ssmtp.conf

Just edit it.

# Config file for sSMTP sendmail
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named


# Where will the mail seem to come from?

# The full hostname
hostname=kvcodes  # Here you have to use your system hostname

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address

That’s it. It will help you to send mail from your Ubuntu localhost by accessing your gmail.

Note : ** if you are using Gmail, you must turn on less secure for the signin of localhost and send email using the gmail smtp.

** You have to change the hostname with your localhost name, you can get it with the below command. hostname on your terminal, you will get your host name and use it there, which I have pointed in green.


About Varadharaj V

The founder of Kvcodes, Varadharaj V is an ERP Analyst and a Web developer specializing in WordPress(WP), WP Theme development, WP Plugin development, Frontaccounting(FA), Sales, Purchases, Inventory, Ledgers, Payroll & HRM, CRM, FA Core Customization, PHP and Data Analyst. Database Management Advance Level


  1. commenter

    Thanks Buddy… Really good article… Neat Explanation… And of course it’s worked for me 100%.

Comment Below

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


Current ye@r *