当我在表单中输入电子邮件a@gmail.com时。在gmail中显示(表格:b@gmail.com)。每当有人输入电子邮件时,它都不会在gmail中显示其电子邮件,而只会显示b @ mail形式。为什么?????我的代码有问题吗
<?php
$result = "";
if (isset($_POST['submit'])) {
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Username = 'b@gmail.com';
$mail->Password = ''; // i provided my password but i cann't show you guys
$mail->setFrom($_POST['email'], $_POST['name']);
$mail->addAddress('b@gmail.com');
//$mail->addReplyTo($_POST['email'],$_POST['name']);
$mail->isHTML(true);
$mail->Subject = 'Form Submission:' . $_POST['subject'];
$mail->Body = '<h1 align=center>Name:' . $_POST['name'] . '<br>Email:' . $_POST['email'] . '<br>Message:' . $_POST['msg'] . '</h1>';
if (!$mail->send()) {
$result = "something went wrong";
} else {
$result = "Thanks " . $_POST['name'] . " for contacting us.We'll get back soon!";
}
}
?>