How To Send Mail From Localhost XAMPP Using Gmail in Hindi

How To Send Mail From Localhost XAMPP Using Gmail in Hindi

Send Mail From Localhost XAMPP Using Gmail: Today i’ll discuss about how to send mail using php through smtp. Its very useful to every developer now days because every developer must create a website on local server then live. Please read carefully every step How To Send Mail From Localhost XAMPP Using Gmail in Hindi, Send Mail From Localhost XAMPP Using Gmail in Hindi, Send Mail From Localhost XAMPP Using Gmail SMTP, How to send email from localhost in php, Send Mail From Localhost XAMPP Using Gmail.

You’ll have face hassle sending e-mail out of your localhost server XAMPP, WAMP, LAMP. As a result of While you setup apache in native system it gained’t by default setup for SMTP server . So if you wish to ship e-mail out of your localhost you need to must setup SMTP configuration in your file or it’s a must to use exterior SMTP server.

There are lot’s of exterior SMTP server can be found like Gmail, Hotmail, Yahoo and so on. They help you ship e-mail by utilizing their SMTP configuration, you solely have to configure some parameter in your native configuration or in your phpmailer code. Create Multilingual Website in HTML

Configure XAMPP to send mail from localhost in Hindi

Following these Steps what you required for it:

  • You have Gmail account. (With Less secure apps on)
    1. you need to change account access for less secure apps By doing following steps.
      1. Login to your google account.
      2. Go to the Less secure apps settings page https://www.google.com/settings/security/lesssecureapps
      3. From Access for less secure apps section, select Turn on.
  • XAMPP activate in Your computer/laptop
  • Swift Mailer Library. if it not Please download here.

 

How to Configure XAMPP to send mail from localhost

Next Go to your Xampp – Htdocs folder and open your directory now create a page index.php and paste the following code.

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
  <h2>Horizontal form</h2>
  <form class="form-horizontal" action="sendemail.php" method="POST">
  <div class="form-group">
      <label class="control-label col-sm-2" for="email">Name:</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" id="email" placeholder="Enter name" name="name">
      </div>
    </div>
	<div class="form-group">
      <label class="control-label col-sm-2" for="email">Phone:</label>
      <div class="col-sm-10">
        <input type="text" class="form-control" id="email" placeholder="Enter phone" name="phone">
      </div>
    </div>
    <div class="form-group">
      <label class="control-label col-sm-2" for="email">Email:</label>
      <div class="col-sm-10">
        <input type="email" class="form-control" id="email" placeholder="Enter email" name="email">
      </div>
    </div>
    <div class="form-group">
      <label class="control-label col-sm-2" for="pwd">Message:</label>
      <div class="col-sm-10">          
        <textarea class="form-control" rows="5" name="message" id="comment"></textarea>
      </div>
    </div>
    <div class="form-group">
      <label class="control-label col-sm-2" for="pwd">Country:</label>
      <div class="col-sm-4">          
         <select class="form-control" name="country" id="sel1">
    <option value="">Select Country</option>
    <option value="India">India</option>
    <option value="Australia">Australia</option>
    <option value="Spain">Spain</option>
  </select>
      </div>
    </div>
    <div class="form-group">        
      <div class="col-sm-offset-2 col-sm-10">
        <button type="submit" name="submit" class="btn btn-default">Submit</button>
      </div>
    </div>
  </form>
</div>
</body>
</html>

 

Send Mail using Gmail with PHP in XAMPP

In Next Step you create new Page sendmail.php because we use in form-action.

  <?php
            if(isset($_POST['submit'])){
            $name=$_POST['name'];
			$phone=$_POST['phone'];
			$email=$_POST['email'];
			$message=$_POST['message'];
			$country=$_POST['country'];
			
			
	require 'vendor2/autoload.php'; //Important library for using Swift Mail
     $transport = (new Swift_SmtpTransport('smtp.gmail.com', 587, 'tls'))
    ->setUsername('hindikavitXXX@gmail.com') // Your Gmail Username
   ->setPassword('XXXXXXXXX'); // Your Gmail Password
	$mailer = new Swift_Mailer($transport);

// Create a message



    $message = (new Swift_Message('New Google SMTP ENQUIRY USING LOCALHOST ')) // Here is the Subject of the Message
    ->setFrom([$email => 'GOGGLE SMTP']) // can be $_POST['email'] etc...
    ->setTo(['another_email_id'] ) // your email eg  / multiple supported eg .
    ->setBody('Dear Sir/Mam,'.
    "<br><br>Here is the New Enquiry for Your Webpage is Following: <br><br>
	Name: $name<br>
	Phone: $phone<br>
	Email: $email<br>
	Message: $message<br>
	Country: $country<br><br>
	Thanks & Regards<br>
    Team Hindi Kavita Shayari<br>hindikavitaajay@gmail.com"
    ,'text/html');
	
	
// Send the message
    if ($mailer->send($message)){
           
				echo "<script> window.alert('Query Successfully Send to Admin');</script>";
				echo "<script> window.open('index.php', '_self');</script>";
	}
	echo "<script> window.alert('Query Successfully Send to Admin');</script>";
	echo "<script> window.open('index.php', '_self');</script>";
             }
         
            ?>

Here is your file look like these:

How To Send Mail From Localhost XAMPP Using Gmail in Hindi

 

Send Mail From Localhost XAMPP Using Gmail in Hindi

Now Check Your Email your Query successfully received. If you are live these site so in your company mail only change smtp details and username, password thats it..

Any doubts on the topic? Please mention them in the Comments section below and I’d be glad to help you out.

Read More Article Like: How to Create Blog on Blogger, Download Youtube Videos 

Now your email will be sent successfully. Have a good day and please share your story in the comment box.

One thought on “How To Send Mail From Localhost XAMPP Using Gmail in Hindi”

Leave a Reply

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