How To Use PhpMailer in Contact Form-
Hello Friends Ajj Me Apko Btaunga Ki Kis Prakar Ham Phpmailer Library Ka Use Karke Contact Form Bana Sakte Hai.Ye Bhut He Easy Hai Aap Sirf 5 Minute Ke Ander Contact Form Teyar Kar Sakte Ho Phpmailer Library Ka Use Karke.
Language Used-
· Html –Yanha Ham Html Ka Use Karke Ek Form Teyar Karege Janha Se User Input Karega
· Php –Php Me Ham Yanha Post Method And Php Mailer Library Ka Use Karege Jiski Madad Se User Ke Dwara Input Kiya Gya Data Website Owner Means Jo Email Id Hamne Coding Me Use Ki Hai Us Email Id Par Data Recive Hoga.Yanha Hma phpmailer smtp ka Use Karege.
· Jquery- Yanha Ham Jquery Ka Use Karke Validation Lagayege
Note- Aap Css And Bootstrap Ka Use Karke Ise Mobile Responsive Bana Sakte Hai
Steps-
Sabse Pehle Aap index.php Name Ki File Create Kar Lijiye
Ab Aap Index.Php File Me Niche Diye Gye Code Ko Yanha Se Copy Karke Paste Kar Dijiye
<html>
<head>
<script>
function validateForm() {
var x = document.forms["myForm"]["email"].value;
if (x == "") {
alert("email must be filled out");
return false;
}
var x = document.forms["myForm"]["subject"].value;
if (x == "") {
alert("subject must be filled out");
return false;
}
var x = document.forms["myForm"]["message"].value;
if (x == "") {
alert("message must be filled out");
return false;
}
}
</script>
</head>
<body>
<form name="myForm" action="" onsubmit="return validateForm()" method="post">
to<input type="email" name="email"><br> subject<input type="text" name="subject"><br>
message<textarea rows="7" cols="60" name="message"> </textarea>
<input type="submit" name="submit">
</form>
</body>
</html>
<?php
require_once 'PHPMailer-master/class.phpmailer.php';
require 'PHPMailer-master/PHPMailerAutoload.php';
$mail = new PHPMailer();
if(isset($_POST['submit']))
{
$email = $_POST['email'];
$subject =$_POST['subject'];
$text_message = "Hello";
$message = $_POST['message'];
//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 = "yourgmailidhere";
$mail->Password = "yourgmailpasswordhere";
//If SMTP requires TLS encryption then set it
$mail->SMTPSecure = tls;
$mail->Port = 465;
//Set TCP port to connect to
$mail->From = "yourgmailidhere@gmail.com ";
$mail->FromName = "yourformname";
$mail->AddAddress("enteremailherewhereyouwantuserinput@gmail.com");
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AltBody = $message;
if(!$mail->send())
{
echo "Email Not Exit";
}
else
{
echo "Your message has been sent successfully ";
}
}
?>
Yanha Apko Sirf Gmail Id Me Apni Gmail Id Dalni Hai And Password Me Apne Gmail Id Ka Password Is Parkar Easily Apka Contact Form Teyar Ho Jayega Or Jab Be User Is Contact Form Me Koi Be Information Enter Krke Submit Karega Wo Sare Information Apki Email Id Par Apko Recive Hogi
Me Ummid Karta Hu Ki Apko Hmare Ye Post(phpmailer tutorial) Achi Lagi Hogi Agar Apka Koi Be Swal Ho To App Mujse Comment Section Me Puch Sakte Hai Me Apki Puri Sahayta Karne Ki Koshish Karunga
Thank You
Team Gajabwap Web In Hindi
ConversionConversion EmoticonEmoticon