这是我的email.php页面编码。现在我从联系表格中收到邮件。但是,我无法更改回复电子邮件ID。在这里,我添加了$mail->AddReplyTo($email, 'Reply');
。但是,它没有在回复选项中显示emailid(联系表单发件人emailid)。
我在这里发布了一张图片。在快速回复选项中,我可以看到接收端电子邮件ID。如何添加电子邮件ID的回复(联系表单发件人emailid)?
<?php
require_once('phpmailer/class.phpmailer.php');
$mail = new PHPMailer;
$name = trim($_POST["name"]);
$typeofmotor = trim($_POST["typeofmotor"]);
$email = trim($_POST["email"]);
$mail->IsSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup server
$mail->Port = 587;
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'email@gmail.com'; // SMTP username
$mail->Password = '1234567890'; // SMTP password
$mail->SMTPSecure = 'tls';
$mail->FromName = $name;
$mail->AddAddress('email@gmail.com', ''); // Add a recipient
$mail->AddReplyTo($email, 'Reply');
$mail->AddBCC('');
$mail->WordWrap = 50;
$mail->IsHTML(true); // Set email format to HTML
$mail->Subject = 'subject name';
$mail->Body = "<!DOCTYPE html>
<html lang='en-us'>
<head>
<meta charset='utf-8'>
<title></title>
</head>
<body>
<table width=550 style=\"border: 1px solid #333333;\" border=0 align=center cellpadding=0 cellspacing=0>
</table>
</body>
<html>";
if(!$mail->Send())
{
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
else
{
echo '<script type="text/javascript"> alert("Message has been sent"); </script>';
echo '<script type="text/javascript"> window.location = "contact.php"; </script>';
}
?>
答案 0 :(得分:0)
而不是:
$mail->FromName = $name;
$mail->AddAddress('email@gmail.com', ''); // Add a recipient
$mail->AddReplyTo($email, 'Reply');
尝试使用它:
$mail->AddReplyTo($email, 'Reply');
$mail->SetFrom('mailbox@name.com', 'Mailbox name');
$mail->AddAddress('email@gmail.com', '');
<强>注意:强> 需要在起始地址
之前添加对地址的回复