Quick way – Configure XAMPP To Send Mail Through Localhost 2019?

configure xampp to send mail through localhost

Succeed With CONFIGURE XAMPP TO SEND MAIL THROUGH LOCALHOST 2019 In 5 MINUTES?

As we all know that sending mail in xampp through localhost can be much more painful if we don't know to configure xampp to send mail through localhost.

Then I thought it will be helpful to all if I can provide them with an easy solution. After spending my quality time on research finally, I came up with a solution which I am disclosing here.

Xampp is the local best server for PHP, Perl, and MySQL.XAMPP helps to create and develop your own applications using Web services technologies. Many people know from their own experience that it. Easy to use control panel. Let's come to the point of xampp setup to send mail through localhost.

configure xampp to send mail through localhost

Here are the steps :

Set SMTP host and port in  php.ini.
Set sendmail_path = "{path to xampp}\sendmail\sendmail.exe\" -t" in php.ini
In sendmail.ini under sendmail folder in xampp, set
smtp_server to what you have set in php.ini
smtp_port
smtp_ssl
auth_username
auth_password
force_sender
hostname
Simply call the mail function with all the arguments properly passed

 

Step 1 :

Let's write the PHP code in our editor can be Notepad++, PhpStrom, Sublime Text

The PHP code is shown in below:

How to configure XAMPP to send mail from localhost

Step 2:

we can send mail from localhost with sendmail package, Sendmail package is in build in XAMPP.

So if you are using XAMPP then you can easily send mail from localhost.

for example, you can configure C:\xampp\php\php.ini and c:\xampp\sendmail\sendmail.ini for Gmail to send mail.

In C:\xampp\php\php.ini find extension=php_openssl.dll and remove the semicolon from the beginning of that line to make SSL working for Gmail for localhost.

Step 3:

in php.ini file find [mail function] and change

SMTP= smtp.gmail.com
smtp_port=587
sendmail_from = [email protected]
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

Now Open C:\xampp\sendmail\sendmail.ini. Replace all the existing code in sendmail.ini with following code

Step 4:

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
[email protected]
auth_password=my-gmail-password
[email protected]
Now you have done!! create php file with mail function and send mail from localhost.

Note: don't forget to replace my-Gmail-id and my-Gmail-password in above code.
Also, don't forget to remove duplicate keys if you copied settings from above.
For example comment following line if there is another sendmail_path: sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe" in the php.ini file

Remember not to forget to restart xampp control panel so the changes take effect.

Click below links for the video tutorial :

Mail through localhost php
Mail through local host php 2018--- Updated

 

Follows the second method if the first method does not work for you :

You have to configure SMTP on your server

You can use the googles free SMTP server Pretty easy to set up too.

  1. <?php
  2. $mail = new PHPMailer(true);
  3. //Send mail using gmail
  4. if($send_using_gmail){
  5.  $mail->IsSMTP(); // telling the class to use SMTP
  6.  $mail->SMTPAuth = true; // enable SMTP authentication
  7.  $mail->SMTPSecure = "ssl"; // sets the prefix to the servier
  8.  $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
  9.  $mail->Port = 465; // set the SMTP port for the GMAIL server
  10.  $mail->Username = "[email protected]"; // GMAIL username
  11.  $mail->Password = "your-gmail-password"; // GMAIL password
  12. }
  13.  
  14. //Typical mail data
  15. $mail->AddAddress($email, $name);
  16. $mail->SetFrom($email_from, $name_from);
  17. $mail->Subject = "My Subject";
  18. $mail->Body = "Mail contents";
  19. try{
  20.  $mail->Send();
  21.  echo "Success!";
  22. } catch(Exception $e){
  23.     //Something went bad
  24.  echo "Fail :(";
  25. }
  26.  
  27. ?>
Er Gopal Bogati

Er Gopal Bogati

My name is Gopal Bogati. I am computer engineer by education, fascinating lover of new technology, fond of writing and reading tech-related articles, Youtuber and Blogger by passion, working as a software engineer in the field of Web Development, fond of spending time on solving tech-related issues.
Er Gopal Bogati
Er Gopal Bogati

Author: Er Gopal Bogati

My name is Gopal Bogati. I am computer engineer by education, fascinating lover of new technology, fond of writing and reading tech-related articles, Youtuber and Blogger by passion, working as a software engineer in the field of Web Development, fond of spending time on solving tech-related issues.