How to send auto response email in PHP


How to send auto response email in PHP


Hello friends ajj me apko autoresponce email ke bare me btaunga.

Autoresponse email kya hai or iska use kiu kiya jata hai-

App logo ne dekha hoga ki jab ham internet me kisi website me signup ,register karte hai to us website ke dwara automatically hmare email id par  thanks ka message bhej diya jata hai.iska fayda ye  hota hai ki user ko confermation mil jati hai mail ke dwara ki   uska form ,data successfully register ho chukka hai.





Yanha ham php mailer library ka use karke user ke mail id par autorespoce message send karege.




Steps-make a index.php file

index.php


<center><!DOCTYPE html>

<html>

<body>

<fieldset>

<form method="post" action="mail.php">

<h1> Autoresponse Contact Form</h1>

Firstname:<br>

<input type="text" name="first_name">

<br>

Lastname:<br>

<input type="text" name="last_name">

<br>

Cityname:<br>

<input type="text" name="city_name">

<br>

EmailId:<br>

<input type="email" name="email">

<br><br>

<input type="submit" name="save" value="submit">

</form>

</fieldset>

</body>

</html>

</center>







Step2-make a mail.php
mail.php





<center>


<?php


$conn=mysqli_connect("localhost","root","","autoresponse");




$first_name = $_POST['first_name'];


$last_name = $_POST['last_name'];


$city_name = $_POST['city_name'];


$email = $_POST['email'];




//here we check the email id is laready exit or not


$query1 = "SELECT * FROM Users WHERE email='$email'";








$res_u = mysqli_query($conn, $query1);








if (mysqli_num_rows($res_u) > 0) {




echo "email id already exit try different email";








  }else{




  //if email id not exits then user data goes in mysql database and also goes a thanks message to user email id




mysqli_query($conn,"insert into users(first_name,last_name,city_name,email) values ('$first_name','$last_name','$city_name','$email')") or die(mysqli_error());




require 'PHPMailer-master/PHPMailerAutoload.php';




$mail = new PHPMailer();




  //Enable SMTP debugging.


  $mail->SMTPDebug = 0;


  //Set PHPMailer to use SMTP.


  $mail->isSMTP();


  //Set SMTP host name


  $mail->Host = "smtp.gmail.com";


  $mail->SMTPOptions = array(


                    'ssl' => array(


                        'verify_peer' => false,


                        'verify_peer_name' => false,


                        'allow_self_signed' => true


                    )


                );


  //Set this to true if SMTP host requires authentication to send email


  $mail->SMTPAuth = TRUE;


  //Provide username and password


  $mail->Username = "yourgmilid";//enter your gamil id here


  $mail->Password = "yourgmailpassword";//enter your gmail password here


  //If SMTP requires TLS encryption then set it


  $mail->SMTPSecure = "false";


  $mail->Port = 587;


  //Set TCP port to connect to




  $mail->From = "bhupenderkashyap122@gmail.com";


  $mail->FromName = "jignesh";




  $mail->addAddress($_POST["email"]);




  $mail->isHTML(true);






  $mail->Subject = "test mail";


  $mail->Body = "Thanks For Register With Us Our Team Contact You Shortley";


  $mail->AltBody = "This is the plain text version of the email content";


  if(!$mail->send())


  {


   echo "Mailer Error: " . $mail->ErrorInfo;


  }


  else


  {


   echo "<h1>Message has been sent successfully</h1>";


  }




  }


  ?>




  </center>





Apko sirf mail.php file  code me  apni gmail id and password enter karke code ko save kar dena hai.





Step3- app data store karne ke liye mysql database create kar lijiye

CREATE TABLE `users` (

`userid` int(8) NOT NULL,

`first_name` varchar(55) NOT NULL,

`last_name` varchar(55) NOT NULL,

`city_name` varchar(55) NOT NULL,

`email` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Aap niche diye gye link se complete php code download kar lijiye autoresponse email ka.

Download Full code



Agar apko post achi lagi to apne friends ke sath jarrur share karna .and agar koi problem a rhe hai to aap comment me puch sakte ho

Thank you

Team gajabwap web in hindi



Previous
Next Post »

1 comments:

Click here for comments
Unknown
admin
25 June 2018 at 12:13 ×

very interesting code my bro.......... you saved my full day thanks for this nice. code keep it up

Congrats bro Unknown you got PERTAMAX...! hehehehe...
Reply
avatar
Thanks for your comment