From 7b704005ba88be324c77e99ced44608ac91c5b82 Mon Sep 17 00:00:00 2001 From: Abhishek Panthee <80570587+abhishekpanthee@users.noreply.github.com> Date: Tue, 19 Mar 2024 20:12:44 +0545 Subject: [PATCH] Update contact.php --- contact.php | 74 ++++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/contact.php b/contact.php index 063f819..5056ff6 100644 --- a/contact.php +++ b/contact.php @@ -5,46 +5,44 @@ use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; -if(isset($_POST['send'])) -{ - $name = $_POST['name']; - $email = $_POST['email']; - $msg = $_POST['message']; -} -$fe_value = $name . " " . $email . " " . $msg; -echo_r $fe_value; //Load Composer's autoloader require 'PHPMailer/Exception.php'; require 'PHPMailer/PHPMailer.php'; require 'PHPMailer/SMTP.php'; -echo "20"; -//Create an instance; passing `true` enables exceptions -$mail = new PHPMailer(true); -echo "23"; -try { - //Server settings //Enable verbose debug output - $mail->isSMTP(); //Send using SMTP - $mail->Host = 'smtp.gmail.com'; //Set the SMTP server to send through - $mail->SMTPAuth = true; //Enable SMTP authentication - $mail->Username = 'abhishekpanthee5@gmail.com'; //SMTP username - $mail->Password = 'mfthljozqjzyygji'; //SMTP password - $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption - $mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` - - //Recipients - $mail->setFrom('abhishekpanthee5@gmail.com', 'Contact-Form'); - $mail->addAddress('abhishekpanthee5@gmail.com', 'Owner'); //Add a recipient - - - //Optional name - - //Content - $mail->isHTML(true); //Set email format to HTML - $mail->Subject = 'Contact -form'; - $mail->Body = "Sender Name -$name
Sender Email - $email
Message - $msg"; -n - $mail->send(); - echo 'Message has been sent'; -} catch (Exception $e) { - echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; + +if(isset($_POST['send'])) { + $name = $_POST['name']; + $email = $_POST['email']; + $msg = $_POST['message']; + + //Create an instance; passing `true` enables exceptions + $mail = new PHPMailer(true); + + try { + //Server settings + $mail->isSMTP(); //Send using SMTP + $mail->Host = 'smtp.gmail.com'; //Set the SMTP server to send through + $mail->SMTPAuth = true; //Enable SMTP authentication + $mail->Username = 'abhishekpanthee5@gmail.com'; //SMTP username + $mail->Password = 'mfthljozqjzyygji'; //SMTP password + $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption + $mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` + + //Recipients + $mail->setFrom('abhishekpanthee5@gmail.com', 'Contact-Form'); + $mail->addAddress('info@abhishekpanthee.com.np', 'Owner'); //Add a recipient + + //Optional name + + //Content + $mail->isHTML(true); //Set email format to HTML + $mail->Subject = 'Contact -form'; + $mail->Body = "Sender Name - $name
Sender Email - $email
Message - $msg"; + + $mail->send(); + echo 'Message has been sent'; + } catch (Exception $e) { + echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; + } } +?>