Я новичок в php.и теперь я хочу настроить отображение $ contact_name при отправке электронной почты?Ниже мой код и, пожалуйста, исправьте мой код.при получении электронной почты всегда отображается «$ contact_name», а не «мое имя»
<?php
if(isset($_POST['send_email']))
{
require_once('../src/PHPMailer.php');
require_once('../src/SMTP.php');
require_once('../src/Exception.php');
require_once('../vendor/autoload.php');
$mail = new phpmailer\phpmailer\PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 2; // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup server
$mail->Port = 587; // Set the SMTP port
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'mygmail@gmail.com'; // SMTP username
$mail->Password = 'mypassword'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$contact_name = $_POST['contact_name']; // required
$mail->From = 'mygmail@gmail.com';
$mail->FromName = 'No Reply';
$mail->AddAddress('togmail@gmail.com'); // Add a recipient
$mail->AddAddress; // Name is optional
$mail->IsHTML(false); // Set email format to HTML
$mail->Subject = 'Add Contact';
$mail->Body = 'Dear All, ($contact_name) with $contact_ext has been addeds.';
if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Message has been sent';
}
?>