How to Send Email with XAMPP on Windows XP

When we are working on a new web application we usually test our projects locally before making them public. But, localhost doesn’t have all the good stuff available on the real host. Some functions need to be configured properly and some additional programs need to be implemented.


I was working on PHP/MySQL based small project which is all about students’ registration system, where the students can register themselves then they’ll be able to receive school transcripts and such stuff by email.

When I finished the project I tested the application to see if it was working properly but I got a problem with PHP‘s mail() function, which was not sending any email messages out.

I was feeling frustrated for a while before coming up with the solution below.


To make our locally hosted web applications talk to any SMTP server including those on the Internet, we will configure that by using the PHP‘s configuration file called php.ini which can be found in the following locations (assuming you are using XAMPP installed in drive C:/):


Okay, that was locating the configuration files; let’s move to the next steps.

Method 1:

– Open php.ini file and uncomment the php_smtp.dll extension. This is required when sending emails to a remote server.

– Scroll down and find the following lines:

[mail function]
; For Win32 only.
;SMTP = localhost
;smtp_port = 25

; For Win32 only.
;sendmail_from = [email protected]

– From the lines above, uncomment SMTP, smtp_port and sendmail_from
directives, then add SMTP server, SMTP port number and your preferred email address to SMTP, smtp_port and sendmail_from directives respectively, your final code should be similar to the one below:

[mail function]
; For Win32 only.
smtp_port = 25

; For Win32 only.
sendmail_from = [email protected]

– Replace and [email protected] with correct values. The defualt SMTP port number is “25”, therefore, you have 99% chance of not changing this.

– Restart your server.

Everything should work properly now. If not, double check your changes again. If you think you made everything correct, but there is nothing working, try method 2 instead.

NB: You should be aware that once you assign an email address to sendmail_from PHP will force all the senders’ emails to that address.

Method 2:

This method is more easier than the steps described in method 1. We’ll use fake Sendmail Program for Windows (sendmail.exe) which is a simple windows console application that emulates sendmail's "-t" option to deliver emails piped via stdin. sendmail.exe is bundled with XAMPP so you don’t need to install it unless you are using hand made server.

– In method 1 we have enabled SMTP, smtp_port and sendmail_from directives, please make sure that these directives are commented out since we don’t need them anymore. Then scroll down and find the following two lines in your php.ini file:

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = "C:\<xampp-installation-path>\sendmail\sendmail.exe -t"

– Make sure that the sendmail_path directive is not commented out, and the path is correct, then save php.ini and close it.

Edit Sendmail Configuration File (sendmail.ini):

The fake Sendmail program is found in the following location:


…and its configuration file is found here:


Okey. That was that. Let’s configure it, so it will work the way we wanted.

– Open sendmail.ini file and use the following settings:


; you must change to your smtp server,

; smtp port (normally 25)

– Replace with a valid SMTP server and assign port number (usually 25) to smtp_port.

Your SMTP server may require an authentication. If this is the case, scroll down the file and find the following lines:

; if your smtp server requires authentication, modify the following two lines


– Modify the above two directives. Add your SMTP server’s username and password.

Some SMTP servers use POP3. If yours is one of those servers, then you need further modifications.

; if your smtp server uses pop3 before smtp authentication, modify the
; following three lines

– Change the values of the above three directives to fit your needs and save your file. Then restart your server and try to send a test message to your email address.

If everything is correct, you can send emails to any server now. The following snippet is a header of message sent from my localhost server:

Envelope-to: [email protected]
Delivery-date: Sun, 15 Jun 2009 17:18:55 +0200
Received: from [] (helo=mehmett)
     by with esmtpa (Exim 4.62)
     (envelope-from )
     id 1MFrTy-000CQx-OY
     for [email protected]; Sun, 15 Jun 2009 17:18:55 +0200
To: [email protected]
Subject: Taste email from localhost
Date: Sun, 15 Jun 2009 19:18:39 +0400
From: J Mehmett
X-Priority: 3
X-Mailer: PHPMailer ( [version 2.0.4]
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="UTF-8"

That was easy, huh?

Final Thoughts

This is a simple mail configuration. I tested it using the SMTP settings of my host and it worked properly.

Gmail users may check Brett Shaffer’s solution, alternatively, AOL users may see KahWee’s solution.

If you have enjoyed reading this post don’t forget to share your thoughts in the comments section.


  1. Chris says:

    I followed your post from google and I am really very happy to admit that it works.

    Method #2 worked for me like a marathon. My machine sends out messages like a real host.

    Thank you any way,

    – Chris

  2. BGBoy says:

    I am using a project management program on xampp and we couldn’t find a solution to send or receive emails through xampp. You saved our day.


  3. Alfonso says:

    Hi. This is the greatest XAMPP/PHP/ sending emails tutorial. I was searching this for several days and I would be frustrated if I didn’t get this post. Thanks

  4. RC says:

    I’m trying to use method #2 with Gmail but seem to be stuck. Did anyone who is running SMTP through Gmail have to add the pop3 settings in sendmail.ini, or just the and login?


  5. Ronak Sah says:

    Hi thnks for the post.. But can you let me know how should I send email from local host using my gmail account..

  6. Sreekanth Reddy says:

    I want to send mail slowly , i mean 4 0r 5 per minute , is there any rule or function or feature in any program , please let me know , is this works for sending mail to inbox

  7. susie says:

    it seem work, but the email that i post doesnot sent to my email…
    could you tell me how do i get my smtp server? maybe i placed a wrong name….

  8. Keith Davis says:

    Hi J

    I’m using the cformsII contact form plugin on a local WordPress installation on XAMPP (using windows vista).

    Trying to get the form to send out emails.

    I’ve tried both of your methods without any luck.

    Any suggestions?

  9. tuankaka says:

    Thank you for your post, however when i used method 2 to send email to my gmail address, the email sent but in my gmail inbox, i found no new email. Could anyone help me with this? thanks.

  10. patd says:

    I use xampp on windows, what I need is not to send real mail during testing, but if there is a way that I can see the mails any where locally how they will look after sending.

    is it possible?

  11. antony says:

    it isn’t work for me, and make me headache for 5 days, pls help me,

    it's my php.ini :
    [mail function]
    ; For Win32 only.
    ;SMTP = localhost
    ; SMTP = [email protected]
    ;smtp_port = 25
    ; For Win32 only.
    ;sendmail_from = [email protected]
    ; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
    sendmail_path = ""C:/program files/xampp/sendmail/sendmail.exe" -t"
    ; Force the addition of the specified parameters to be passed as extra parameters
    ; to the sendmail binary. These parameters will always replace the value of
    ; the 5th parameter to mail(), even in safe mode.
    ;mail.force_extra_parameters =
    ; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
    mail.add_x_header = Off
    ; Log all mail() calls including the full path of the script, line #, to address and headers
    mail.log = "C:xamppapachelogsphp_mail.log"
    and it's my sendmail.ini:
    ; configuration for fake sendmail
    ; if this file doesn't exist, sendmail.exe will look for the settings in
    ; the registry, under HKLMSoftwareSendmail
    ; you must change to your smtp server,
    ; or to IIS's "pickup" directory.  (generally C:InetpubmailrootPickup)
    ; emails delivered via IIS's pickup directory cause sendmail to
    ; run quicker, but you won't get error messages back to the calling
    ; application.
    ; smtp port (normally 25)
    ; the default domain for this server will be read from the registry
    ; this will be appended to email addresses when one isn't provided
    ; if you want to override the value in the registry, uncomment and modify
    ; log smtp errors to error.log (defaults to same directory as sendmail.exe)
    ; uncomment to enable logging
    ; create debug log as debug.log (defaults to same directory as sendmail.exe)
    ; uncomment to enable debugging
    ; if your smtp server requires authentication, modify the following two lines
    [email protected]
    ; if your smtp server uses pop3 before smtp authentication, modify the
    ; following three lines
    pop3_username= antonyvesta
    pop3_password= ******
    ; to force the sender to always be the following email address, uncomment and
    ; populate with a valid email address.  this will only affect the "MAIL FROM"
    ; command, it won't modify the "From: " header of the message content
    [email protected]
    ; sendmail will use your hostname and your default_domain in the ehlo/helo
    ; smtp greeting.  you can manually set the ehlo/helo name if required

    Have I miss something here? pls help me

Comments are closed.