phpmailer 不发送变量


phpmailer not sending variables

我正在尝试使用phpmailer从html表单发送用户的输入

形式是这样的

<form action="senditpm.php" role="form">
<input type="text" class="form-control" id="name" name="name"><br>
<input type="email" class="form-control" id="email" name="email">>br>
<input type="text" class="form-control" id="phone" name="phone">>br>
<input type="submit" value="Submit" class="submit-button btn btn-default">
</form>

Senditpm.php是这样的

<?php
$name = $_POST['name'];
$phone = $_POST['phone'];
$email= $_POST['email'] ;
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();              
$mail->Host = 'xxxxxxxxx';  
$mail->SMTPAuth = false;                               
$mail->Username = 'xxxxxxxx';                
$mail->Password = 'xxxxxxxx';                           
$mail->Port = 25; 
$mail->setFrom('xxx@xxxxs.co.uk', 'xxxxx');
$mail->addAddress('xxx@xxx', 'xxx xxxx'); 
$mail->isHTML(true);
$mail->Subject = 'Here is the subject';

$mail->Body="
Name: $name <br>
Email: $email <br>
Phone: $phone <br>"; 
;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
  } else {
echo 'Message has been sent';
  }
?>

当我填写表单并单击"提交"时,我收到这样的电子邮件

名字:

电子邮件:

电话:

如您所见,php 不会发送变量请有人让我知道我哪里出错了。提前致谢

如果 POST 方法

不是隐含的,并且您使用的是 POST 数组,则<form>默认为 GET 方法。

所以改变

<form action="senditpm.php" role="form">

<form action="senditpm.php" role="form" method="post">