How to:Start mails in local in Apache (Xampp or Wamp Server)

Hello Friends, Today i am writing this article for starting mails in xampp or wamp server whatever you are using for developing PHP based web application. By default xampp or wamp server don’t have mail facility (using SMTP) ON, So to do this we have to modify some settings to start mail functionality in local using SMTP. I have search a lot on internet and i found this thing very hardly. So if you want to start mail functionality in localhost by SMTP then below are the steps to do it.

1. First make one file(you can name it anything) anywhere in htdocs or www folder having code shown below.for instance i named this file phpinfo.php.

<?php

phpinfo();

?>

2. After that write URL in browser to see this file. When you open this file in browser then you will see so many settings like shown below :

3. Find location of your php.ini file like shown below in image :

4. After finding php.ini file , open php.ini file from that path, for me it is “E:\xampp\php\php.ini”, in your case it can be different then me because i have installed it in E drive and also i have installed xampp. If you use wamp then this path must be different then mine, So from that path open php.ini file.

5. After opening php.ini file try to find out “SMTP” (without quotes) in that file.

6. After finding SMTP , you will find like shown below:

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
sendmail_from = me@localhost.com

7. Change localhost to your with your SMTP server name. for example for gmail smtp server is smtp.gmail.com(like gmail you have smtp server address for you domain name) and change sendmail_from to your email address for that server. for example if we are talking about phpzone.net then smtp server will be smtp.phpzone.net and sendmail_from will be any email address of phpzone.net like abcxyz@phpzone.net. So after adding it will look like shown below ;

[mail function]
; For Win32 only.
SMTP = smtp.phpzone.net
smtp_port = 25
; For Win32 only.
sendmail_from = abcxyz@phpzone.net

Save this file and close it, then restart your xampp or wamp server then try to send mail from local by PHP mail() function. It will start working and you will never get this type of error :

“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”

  • The way you have described about starting mails in xampp or wamp server is very good and useful one.I really liked it.

  • The way you have described about starting mails in xampp or wamp server is very good and useful one.I really liked it.

  • Which one is better to you.I am using WAMP server I can get direct access to mysql console and also I can put it online or offline mode.

  • Which one is better to you.I am using WAMP server I can get direct access to mysql console and also I can put it online or offline mode.

  • Morgan

    Kudos!
    I read 10 other cryptic explanations.
    Your article is concise, clear and easy to understand.

  • Reiko Hoffmeyer

    Quite a beautiful website. I built mine and i was looking for some ideas and your website gave me some. The website was developed by you?

    Thank you

Subscribe to PHP Freelancer

Enter your email address: