0

我有以下代码。如您所见,我将 replyTo 字段设置为在联系我们表单中输入的电子邮件。但是,这不起作用。每次我收到来自我的联系表格的电子邮件时,我都需要复制电子邮件(在我的邮件正文中)并将其粘贴到“收件人”字段中。由于 to 字段将忽略我放置不同回复电子邮件的事实,而只需使用我的网站电子邮件。知道有什么问题吗?

require_once('mailer/class.phpmailer.php');

$mail             = new PHPMailer();

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "smtp.gmail.com"; // SMTP server
$mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
$mail->Username   = "email";  // GMAIL username
$mail->Password   = "password";            // GMAIL password

$mail->SetFrom("mywebsitesemail", "my name");
$mail->AddAddress("mywebsitesemail", "my name");
$mail->AddReplyTo("$email","$name");

$mail->Subject    = "Subject";

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML("$message");



$mail->Send();
4

0 回答 0