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.

37 Comments

      • 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?

        Reply
        • 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 🙂

          Reply
  1. Alieym

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

    Reply
  2. Sivabalan

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

    Reply
  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

    Reply
  4. 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..

    Reply
  5. 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..!!

    Reply
  6. 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??

    Reply
    • 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

      Reply
  7. aa

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

    Reply
    • sandeep

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

      Reply
  8. 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.

    Reply
  9. R Ahmed

    Sending HTML email using PHP

    <?php
    $to = "ahmed.rustam77@gmail.com";
    $subject = "This is subject";

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

    $header = “From: care.rwcs@gmail.com“;

    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 ahmed.rustam77@gmail.com
    ………..
    ……….
    ………

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

    Reply
  10. 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 = ‘zhaider113@gmail.com’;
    $name = ‘Zeeshan’;
    $email_from = ‘shahghafoor439@gmail.com’;
    $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 = “zhaider113@gmail.com”; // 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 :(“;
    }

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *