Send email from xampp localhost

Send email from xampp localhost. Follow the easy steps
  1. Goto http://glob.com.au/sendmail/, download latest sendmail package.
  2. Extract the zip file and copy the files into your \xampp\sendmail folder(Replace every file in the existing folder).
  3. Update the sendmail.ini file in sendmail folder with the following details, and make sure it is not commented(;).

    smtp_server=smtp.gmail.com
    smtp_port=25
    error_logfile=error.log
    debug_logfile=debug.log
    auth_username=yourname@gmail.com
    auth_password=gmailpassword
    force_sender=yourname@gmail.com
    Here i have added gmail account for sending emails.
  4. Open xampp\php\php.ini file find sendmail_path and update its value to "\"C:\xampp\sendmail\sendmail.exe\" -t". Now it will look like below

    sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

    Make sure it's not commented(;)
  5. Restart your apache server.

Now you can send email from xampp localhost! enjoy :-)

Comments

  1. Nice post! now i can able to send email from localhost. It ll help me to check email notifications to users after registration. Thank you karthik

    ReplyDelete
  2. great post it solved my problem that arises during my project work

    ReplyDelete
    Replies
    1. plz send ur full code sir.bcoz myself not working....

      Delete
  3. Hi thanks for the PHP mail post its so clearly explaianed in,

    I am having issues receiving the mails sent from localhost, on my localhost the mailform.php is executed successfully without any error messages but unfortunately I am not receiving the same. Plz do the needful

    ReplyDelete
  4. Sunil Kumar NerellaApril 19, 2013 at 3:57 PM

    Hello Karthik,

    I had done all the settings which were mentioned above but while sending the email, it shows that the mail have been sent but sent email address does't recieve any email from the sent mail....

    Can you explain why it had dappened...?

    ReplyDelete
  5. Hi sunil, please check your debug.log and error.log file in sendmail folder to fine the error.

    ReplyDelete
  6. Hi Raj, please make sure that you have entered correct email and password, check your log files in sendmail folder to find what would be the problem

    ReplyDelete
  7. I've tried all your steps. I've checked "error.log" and "debug.log" and its blank. No error found.

    This is my php code:
    ---------------------------------------------------------------
    $from = FROM_EMAIL;
    $to = TO_EMAIL;
    $subject = FHD_TITLE . ' New Registration';
    // message
    $message = '


    New Registration


    New User Registration
    Name: ' . $name . '
    Login: ' . $login . '
    Email: ' . $email . '


    ';
    $headers = "From:" . $from . "\r\n";
    $headers .="Reply-To: " . $from . "\r\n";
    $headers .="MIME-Version: 1.0" . "\r\n";
    $headers .="Content-type: text/html; charset=iso-8859-1" . "\r\n";
    if (mail($to, $subject, $message, $headers))
    {
    echo "Message Sent";
    }
    else
    {
    echo "Message Sending Failed";
    }

    Message appear on the page is "Message Sent". But no incoming email received.
    Can you help me with this?

    ReplyDelete
  8. Benjie Brian ManalaysayApril 27, 2013 at 11:56 AM

    Hi Can someone help me, I followed all the steps, But it's not working for me, Here's the content on my debug and error file:

    Error: 13/04/27 08:53:06 : Connect timed out.

    Debug:
    13/04/27 08:52:56 ** --- MESSAGE BEGIN ---
    13/04/27 08:52:56 ** To: bbmanalaysay@gmail.com
    13/04/27 08:52:56 ** Subject: This is subject
    13/04/27 08:52:56 ** From:abc@somedomain.com
    13/04/27 08:52:56 **
    13/04/27 08:52:56 ** This is simple text message.
    13/04/27 08:52:56 ** --- MESSAGE END ---
    13/04/27 08:52:56 ** Connecting to smtp.gmail.com:25
    13/04/27 08:53:06 ** Disconnected.
    13/04/27 08:53:06 ** Disconnected.
    13/04/27 08:53:06 ** Disconnected.
    13/04/27 08:53:06 ** Disconnected.
    13/04/27 08:53:06 ** Connect timed out.

    ReplyDelete
  9. I think you could try changing the smtp_port:25 in senmail.ini file to smtp_port:587

    ReplyDelete
  10. Thanks man, i am a newbie to php and the code helps me a lot to test mail function locally...

    ReplyDelete
  11. Hi Sharmishtha Rathod,
    Could you please elaborate your problem? so that we can help you, thanks! :)

    ReplyDelete
  12. It is Working but "From:" address is changing
    From address is showing as we have give in the sendmail.ini can any one Help Me

    ReplyDelete
  13. didn't have a chance to check it in windows 8 friend. I will try this and let you know :)

    ReplyDelete
  14. OK, because I alreadry tried it and it didn't work :)

    ReplyDelete
  15. oh ok.. anyway i will try from my side!!

    ReplyDelete
  16. oh ok, just let me know if you're done with it :)

    ReplyDelete
  17. Hi & thank you very much!
    I have tried many others instructions around the web and after a fat hour of trying nothing work for me!
    I think the key for me was outdated sendmail.exe (year 2009). So update instruction must be crucial.

    How to simply test outside of wordpress?

    1. Create PHP file with code:



    2. Execute

    Greetings, Jurij

    ReplyDelete
  18. plz send me the details of sendmail in xammp using php in windows 7-sumitk223@gmail.com.@karthik

    ReplyDelete
  19. Thanks for your post. I tried same but nothing happened.

    How can I solve it? How to check debug.log and error.log file. I do not see such file in sendmail folder.

    Thanks for your time.

    ReplyDelete
  20. Thanks working perfect

    ReplyDelete
  21. Not Working For Me Man
    The Script Is Running Without error but i am not getting mail in myinbox

    ReplyDelete
  22. That did really solve my problem .. lolthank you very much Nathaniel

    ReplyDelete
  23. this is the perfect answer. but it is not possible to send message from xampp. it means i think you also can purchase the domain for do it.
    from the reply of the all internet users all says not work.. not work.. not work....
    And it is a very critical problem for every web developer.

    ReplyDelete
  24. Hi Siraj,
    Thanks for your feedback. I was used this steps in Win XP localserver. It was worked on that time. I agree that currently this solution is not working for me also(Currently using Win 8). Soon i will update this post with right solution. Thanks!

    ReplyDelete
  25. I have completed every necessary steps and the message is also showing that the mail is sent but i am not receiving any mail at all, if there is any solution please inform me the same

    ReplyDelete
  26. […] In my case, I did everything like in this tutorial:http://www.websnippetz.com/php/send-email-from-xampp-localhost/ […]

    ReplyDelete
  27. Working perfect bro ...

    ReplyDelete
  28. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. It's not working for me on windows 7 .. Not error occur but my email id inbox have not accept any email from localhost.

      Delete
  29. its not working i am using window 8.1.. I follow all the steps that are mentioned but still not able to send mail from localhost plz help me....

    ReplyDelete
  30. its not working ..in error log .. connection time out why ?

    ReplyDelete
  31. help me guyz i am behind the router and my email.php script says email sent but m not getting any email

    ReplyDelete
  32. When send mail then show message sent but didn't received any mail and debug.log give these message

    15/12/17 00:56:14 ** --- MESSAGE BEGIN ---
    15/12/17 00:56:14 ** To: msrasel2014@gmail.com
    15/12/17 00:56:14 ** Subject: Test mail
    15/12/17 00:56:14 **
    15/12/17 00:56:14 ** This is a test mail
    15/12/17 00:56:14 ** --- MESSAGE END ---
    15/12/17 00:56:14 ** Connecting to smtp.gmail.com:587
    15/12/17 00:56:15 ** Connected.
    15/12/17 00:56:15 << 220 smtp.gmail.com ESMTP r193sm6404693pfr.65 - gsmtp
    15/12/17 00:56:15 >> EHLO DATA-SERVER
    15/12/17 00:56:15 << 250-smtp.gmail.com at your service, [103.26.113.218]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
    15/12/17 00:56:15 ** Authenticating as m.bashir07@gmail.com
    15/12/17 00:56:15 >> STARTTLS
    15/12/17 00:56:16 << 220 2.0.0 Ready to start TLS
    15/12/17 00:56:16 >> EHLO DATA-SERVER
    15/12/17 00:56:16 << 250-smtp.gmail.com at your service, [103.26.113.218]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
    15/12/17 00:56:16 >> AUTH LOGIN
    15/12/17 00:56:16 << 334 VXNlcm5hbWU6
    15/12/17 00:56:16 >> bS5iYXNoaXIwN0BnbWFpbC5jb20=
    15/12/17 00:56:17 << 334 UGFzc3dvcmQ6
    15/12/17 00:56:17 >> MzIxKmJhc2hpcg==
    15/12/17 00:56:17 << 534-5.7.14 534-5.7.14 vfZPrTMhB77ph5J959E06h0qAycU3BMz5nmUl0yPlVKigeDpPeTjw9P4Lwu-fmEOiEXCxR534-5.7.14 RNWokOSDINJzOehfEjXTt6OGI15QS_56nCdEeQ_jLVL0HMkm1kRUR7LQNi4WLCdIjG8WVK534-5.7.14 j_CKlZGiG6SRq5gL26WXWseFHHgVyqbbeM2u_wiY6QLOiTj7K_JnfRMCjbKyNFsEnRSZDZ534-5.7.14 zvOLNgzE4pO-PSo8vm_FPJzo7ZJk> Please log in via your web browser and534-5.7.14 then try again.534-5.7.14 Learn more at534 5.7.14 https://support.google.com/mail/answer/78754 r193sm6404693pfr.65 - gsmtp
    15/12/17 00:56:17 ** Disconnecting from smtp.gmail.com:587
    15/12/17 00:56:17 ** Disconnected.
    15/12/17 00:56:17 ** Disconnected.
    15/12/17 00:56:17 ** vfZPrTMhB77ph5J959E06h0qAycU3BMz5nmUl0yPlVKigeDpPeTjw9P4Lwu-fmEOiEXCxRRNWokOSDINJzOehfEjXTt6OGI15QS_56nCdEeQ_jLVL0HMkm1kRUR7LQNi4WLCdIjG8WVKj_CKlZGiG6SRq5gL26WXWseFHHgVyqbbeM2u_wiY6QLOiTj7K_JnfRMCjbKyNFsEnRSZDZzvOLNgzE4pO-PSo8vm_FPJzo7ZJk> Please log in via your web browser andthen try again. Learn more at https://support.google.com/mail/answer/78754 r193sm6404693pfr.65 - gsmtp

    ReplyDelete
  33. it fails for me .... but thanks for sharing

    ReplyDelete
  34. i followed your tutorials links but unable to receive the email and not getting mails from local xampp server .so could tell me that how to send a mail from local server ......thanks

    ReplyDelete

Post a Comment

Popular posts from this blog

Modify item price in cart after placing order using sales_quote_add_item

Convert long url to short url using tinyurl api