这是我使用PhpMailer用于联系表单的php代码。
<?php
use PHPMailer\PHPMailer\PHPMailer;
include_once "PHPMailer/PHPMailer.php";
include_once "PHPMailer/Exception.php";
include_once "PHPMailer/SMTP.php";
if (isset($_POST['submit'])) {
$subject = $_POST['subject'];
$email = $_POST['email'];
$message = $_POST['message'];
echo $subject . "<br/>";
echo $email . "<br/>";
echo $message . "<br/>";
$mail = new PHPMailer();
$mail->addAddress('example@gmail.com');
$mail->setFrom($email);
$mail->Subject = $subject;
$mail->isHTML(true);
$mail->Body = $message;
if ($mail->send())
echo "Your email has been sent, thank you!";
else
echo "Please try again!";
}
?>
它显示“您的电子邮件已发送,谢谢”,但不发送任何内容。 怎么解决?