Send E-mail From Localhost on Ubuntu with PHP
- Article
- Comment (2)
Introduction
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.
Steps
Just follow the steps.
- 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. #root=postmaster root=****@gmail.com # The place where the mail goes. The actual machine name is required no # MX records are consulted. Commonly mailhosts are named mail.domain.com #mailhub=mail mailhub=smtp.gmail.com:587 AuthUser=****@gmail.com AuthPass=**** UseTLS=YES UseSTARTTLS=YES # Where will the mail seem to come from? #rewriteDomain= rewriteDomain=gmail.com # The full hostname #hostname=MyMediaServer.home 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 FromLineOverride=YES
That’s it. It will help you to send mail from your Ubuntu localhost by accessing your gmail.
Note : ** https://www.google.com/settings/security/lesssecureapps 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.
Thanks Buddy… Really good article… Neat Explanation… And of course it’s worked for me 100%.
You are welcome. And glad you got helped.