How to send mail from localhost in ubuntu 14.04

13,339

your_domainname_here is used for virtual host . So if you are not creating virtual host simply run this command

sudo vim /etc/hosts

and add

127.0.0.1 localhost localhost.localdomain

restart your server

service apache2 restart

hope it will help you

Share:
13,339
PRashant PUrohit
Author by

PRashant PUrohit

Updated on June 04, 2022

Comments

  • PRashant PUrohit
    PRashant PUrohit almost 2 years

    Hello I have tried these command but I am not able to send mail please help me out..

    1) Install sendmail

    Sendmail might already be installed, but just in case, enter this into the server terminal:

    sudo apt-get install sendmail
    

    2) Configure sendmail

    Enter the following command into the terminal and type "Y" for each question it asks:

    sudo sendmailconfig
    

    3) Edit hosts file

    Time to edit your server's hosts file, access it by entering the following command into the terminal:

    sudo vim /etc/hosts
    

    Add the following line to the top of the file and save it:

    127.0.0.1 localhost localhost.localdomain your_domain_name_here.com
    

    Comment out any duplicate lines that already existed.

    4) Restart apache Let's restart your server just for good measure. At this point emails sent via PHP's mail() function should be sending successfully and without much delay.

    sudo service apache2 restart 
    

    I didn't understand the 3rd step because I am working on localhost so how I can add domain name here..

    Any help will be appreciable