Sendgrid电子邮件正在发送,但没有';t包括表单数据


Sendgrid email is delivering, but doesn't include the form data

正如标题所述,电子邮件已收到,但不包括所有数据(姓名、电子邮件、电话、主题、消息)。

<?php
$url = 'https://api.sendgrid.com/';
$user = 'username';
$pass = 'password';
//HTML grab
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$params = array(
    'api_user'  => "$user",
    'api_key'   => "$pass",
    'to'        => "email@gmail.com",
    'subject'   => "Submission Inquiry",
    'html'      => "<html><head><title> Contact Form</title><body>
   Name: $name'n<br>
   Email: $email'n<br>
   Subject: $subject'n<br>
   Message: $message <body></title></head></html>",
    'text'      => "
   Name: $name'n
   Email: $email'n
   Phone: $phone'n
   Subject: $subject'n
   $message",
    'from'      => "email@email.com",
  );

$request =  $url.'api/mail.send.json';
// Generate curl request
$session = curl_init($request);
// Tell curl to use HTTP POST
curl_setopt ($session, CURLOPT_POST, true);
// Tell curl that this is the body of the POST
curl_setopt ($session, CURLOPT_POSTFIELDS, $params);
// Tell curl not to return headers, but do return the response
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// obtain response
$response = curl_exec($session);
curl_close($session);
// Redirect to thank you page upon successfull completion, will want to build one if you don't alreday have one available
header('Location: ../success.html'); // feel free to use whatever title you wish for thank you landing page, but will need to reference that file name in place of the present 'thanks.html'
exit();
// print everything out
print_r($response);
?>

我的网站是http://geniecleaningcare.com

我做错了什么?这是我第一次编写PHP页面!提前感谢您的帮助。

编辑:以下是电子邮件正文的样子:

--===============6352432520243076444==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable

    Name:=20
    Email:=20
    Phone:=20
    Subject:=20
=20=20=20=20=
--===============6352432520243076444==
Content-Type: text/html; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
<html><head><title> Contact Form</title><body>
    Name:=20
<br>
    Email:=20
<br>
    Subject:=20
<br>
    Message:  <body></title></head></html>=
--===============6352432520243076444==--

还有一些其他数据,但都与消息的标题或其他内容有关。

我的区域中没有包含name="字段。。。所以现在是:

<div class="form-group">
     <label for="subject" class="required" name="subject">Subject</label>
     <input type="text" class="form-control" id="subject" placeholder="Subject" name="subject"> 
</div>

现在效果很好。