如标题所述,收到电子邮件,但不包括所有数据(姓名,电子邮件,电话,主题,消息)。
<?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==--
还有一些其他数据,但它们都与消息的主管有关。
答案 0 :(得分:0)
我没有包含名称=&#34; &#34;我所在地区的领域......现在就是这样:
<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>
现在完美运作。