Looking to Build/Redesign a Website or Blog ?

To speak to Rakshit, call +91 968 704 2303

How to send email from localhost(XAMPP or WAMP) in PHP in Windows

Hello Friends,

Whenever you works in local server (XAMPP or WAMP) for developing any email functionality in website, than you might be wonder that why email is not going from localhost(XAMPP or WAMP) in windows environment. Well, i faced the same situation and in this case i can help you. Below is the error you might get when working with email.

"Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in"

Here i am showing you the way,how to send email from XAMPP or WAMP (localhost) in PHP in Windows.

1) Open the "php.ini". For XAMPP,it is located in C:\XAMPP\php\php.ini. Find out if you are using WAMPP server.

2) Search [mail function] in the php.ini file.

    You can find like below.
        [mail function]
        ; For Win32 only.
        SMTP = localhost
        smtp_port = 25
        ; For Win32 only.
        sendmail_from = me@localhost.com
    Change the localhost to the smtp server name of your ISP. No need to change the smtp_port. Leave it as 25.
    Change sendmail_from from me@localhost.com to your domain email address which will be used as from address..
    So for me, it will become like this.
        [mail function]
        ; For Win32 only.
        SMTP = smtp.programmingfacts.com
        smtp_port = 25
        ; For Win32 only.
        sendmail_from = info@programmingfacts.com

3) Restart the XAMPP or WAMP(apache server) so that changes will start working.

4) Now try to send the mail using the mail() function ,

    mail("raxit4u2@gmail.com","Success","Thanks, that works");

Well that's all, now mail is sent to "raxit4u2@gmail.com" from the localhost.

To know more about programming,JavaScript issues,jQuery,Expression Engine,MYSQL database and Open-source, enter your email address below. We will send you free tutorials.

Enter your email address:
Feel free to ask any question. Just leave your comment below and we will answer your comment with in 24 hours.


Leave a Reply

Your email address will not be published.