Enable Send Email in XAMPP

xampp-gmailI use XAMPP lite 2.5 USB version, and the thing i hate about it is that i cannot test email notification in my WordPress install. This is very crucial to test eCommerce site so i can meke sure the system deliver email to user, or in bbPress to check user subscription is working, and you can also be creative and use it for a very simple email newsletter, etc.

I used to create a live test site just to check this. But not anymore since i found this tutorial How to send email from XAMPP (PHP).

However the tutorial is not working, maybe it’s different XAMPP version. This is the working code i’m using:

Edit your php.ini in “xampp\php\php.ini”

first always make backup, just in case.

And change this in line 1086:

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path = "\"\XAMPP\sendmail\sendmail.exe\" -t"

to:

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 587

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = {your gmail username}@gmail.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "\"\XAMPP\sendmail\sendmail.exe\" -t"

Change {your gmail username} with your own without the bracket.

Edit your sendmail.ini “xampp\sendmail\sendmail.ini”

Always backup first before editing your sendmail.ini.

comment this two line (just add “;” before it)

smtp_server=localhost
smtp_port=25

to

;smtp_server=localhost
;smtp_port=25

and add this in the bottom of your sendmail,ini:

;new config:
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=tls
error_logfile=error.log
pop3_server=
pop3_username=
pop3_password=
force_recipient=
hostname=

auth_username={your gmail username}@gmail.com
auth_password={your gmail password}
force_sender={your gmail username}@gmail.com
NOTE: You Need to enable SMTP in your GMail to make this work and all sender will be from your email.

39 Comments

    • David

      go to your gmail settingsm click forwarding pop/imap. imap is the smtp, just enable imap.

      • lizz

        Sir, once i run localhost, it said successful..but i didnt receive any email..i have setting the enable imap…i dont know know how to fix this..do you have any suggestion regarding my problem?

        • David

          Sorry, I no longer activate email in XAMPP.
          I don’t know if it’s working/not in latest XAMPP.
          I would suggest using the xampp version as described in my post.

          Good luck 🙂

  1. Alieym

    I’ve done all steps. But no email received in my gmail account.. And also there is no error

  2. Sivabalan

    I followed your steps but mail is not sending please help me
    $to=”[email protected]”;
    $subject=”hai”;
    $body=”hello”;
    if(mail($to,$subject,$body))
    echo “Successful”;
    else
    echo “Unsuccessful”;
    help me do this.

  3. Chakravarthy

    I tried editing these sendmail.ini and php.ini in many ways but none of them worked… I failed everytime sending mail…
    The mails are being stored in mailoutput folder… please help me to sort this out

  4. pp

    Hello, my website is http://prashantmantra.com I want to use email validation in sign up form but problem is that email is not sending out to gmail. Can you tell me how to configure smtp in remote server how to solve it…..?

  5. pp007

    Hello, my website is http://prashantmantra.com I want to use email varification in sign up form but problem is that email is not sending out to gmail. Can you tell me how to configure smtp in remote server how to solve it…..?

  6. phanindra

    what are the values to be given for

    pop3_server=
    pop3_username=
    pop3_password=
    force_recipient=
    hostname=

    Please help ASAP… I am working on it present..

  7. Zvone

    Thank you David for this!

    smtp_ssl=tls was my problem, in my ini was set to auto.

  8. Daxa

    I am also changed my php.ini file as well as sendmail.ini but every time smtp error found and i can’t send mail through localhost..please help me..!!

  9. Prav

    have tried but not working, defined all the configs as required, anyone has a solution?

  10. ircham

    This work good for me, but i have receive email only from gmail, not from email that i entered. just like hajar problem. is there any solution??

    • sandeep

      hey ircham….
      i am not getting mail too for my contact form…i have changd php.ini and sendmail.ini then too
      same as david has given..

      please hellp me

  11. aa

    hello…can u help me? i had followed the steps..but cant receive the mail from localhost… 🙁

    • sandeep

      hey sam….
      i am not getting mail too
      its showing mail is sent but i am not getting mail
      please hellp me

  12. R Ahmed

    Not working.. it takes so many time to run..
    error log
    [Fri Oct 02 02:29:45.721906 2015] [mpm_winnt:notice] [pid 5948:tid 508] AH00456: Apache Lounge VC11 Server built: Jul 17 2014 11:50:08
    [Fri Oct 02 02:29:45.721906 2015] [core:notice] [pid 5948:tid 508] AH00094: Command line: ‘d:\\www\\xampp\\apache\\bin\\httpd.exe -d D:/www/xampp/apache’
    [Fri Oct 02 02:29:45.721906 2015] [mpm_winnt:notice] [pid 5948:tid 508] AH00418: Parent: Created child process 1924
    [Fri Oct 02 02:29:46.249086 2015] [ssl:warn] [pid 1924:tid 512] AH01909: http://www.example.com:443:0 server certificate does NOT include an ID which matches the server name
    [Fri Oct 02 02:29:46.452220 2015] [ssl:warn] [pid 1924:tid 512] AH01909: http://www.example.com:443:0 server certificate does NOT include an ID which matches the server name
    [Fri Oct 02 02:29:46.499103 2015] [mpm_winnt:notice] [pid 1924:tid 512] AH00354: Child: Starting 150 worker threads.

  13. R Ahmed

    Sending HTML email using PHP

    <?php
    $to = "[email protected]";
    $subject = "This is subject";

    $message = "This is HTML message.“;
    //$message .= “This is headline.”;

    $header = “From: [email protected]“;

    echo “Sending test mail to $to …………………………”;

    if(mail($to,$subject,$message))
    echo “Successful”;
    else
    echo “not Successful ………..”;

    $retval = mail ($to,$subject,$message,$header);

    if( $retval == true )
    {
    echo “Message sent successfully… $retval”;
    }
    else
    {
    echo “Message could not be sent… $retval”;
    }
    ?>

    After run:
    Sending test mail to [email protected]
    ………..
    ……….
    ………

    not Successful
    ………..
    Message could not be sent…

  14. zeeshan haider

    I try to send email form localhost to gmail but it cant not send help me anyone. My php code is :
    $mail = new PHPMailer(true);

    $email = ‘[email protected]’;
    $name = ‘Zeeshan’;
    $email_from = ‘[email protected]’;
    $name_from = ‘Ghafoor shah’;

    //Send mail using gmail
    $mail->IsSMTP(); // telling the class to use SMTP
    $mail->SMTPAuth = true; // enable SMTP authentication
    $mail->SMTPSecure = “ssl”; // sets the prefix to the servier
    $mail->Host = “smtp.gmail.com”; // sets GMAIL as the SMTP server
    $mail->Port = 465; // set the SMTP port for the GMAIL server
    $mail->Username = “[email protected]”; // GMAIL username
    $mail->Password = “password”; // GMAIL password

    //Typical mail data
    $mail->AddAddress($email, $name);
    $mail->SetFrom($email_from, $name_from);
    $mail->Subject = “My Subject”;
    $mail->Body = “Mail contents”;

    try{
    $mail->Send();
    echo “Success!”;
    } catch(Exception $e){
    //Something went bad
    echo “Fail :(“;
    }

  15. Lisa Scott

    Enable IMAP on your mail i.e.
    Open Computer -> Your Mail -> Click Settings -> Click Forwarding & POP/IMAP tab.
    In the “IMAP access” section, select Enable IMAP.
    Click Save Changes.

Comments are closed.