Skip to content

Commit

Permalink
Update contact.php
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekpanthee authored Mar 19, 2024
1 parent 6b8b34c commit 7b70400
Showing 1 changed file with 36 additions and 38 deletions.
74 changes: 36 additions & 38 deletions contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '[email protected]'; //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('[email protected]', 'Contact-Form');
$mail->addAddress('[email protected]', 'Owner'); //Add a recipient


//Optional name

//Content
$mail->isHTML(true); //Set email format to HTML
$mail->Subject = 'Contact -form';
$mail->Body = "Sender Name -$name <br> Sender Email - $email <br> 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 = '[email protected]'; //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('[email protected]', 'Contact-Form');
$mail->addAddress('[email protected]', 'Owner'); //Add a recipient

//Optional name

//Content
$mail->isHTML(true); //Set email format to HTML
$mail->Subject = 'Contact -form';
$mail->Body = "Sender Name - $name <br> Sender Email - $email <br> Message - $msg";

$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
}
?>

0 comments on commit 7b70400

Please sign in to comment.