Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将电子邮件从表单发送到gmail帐户的最简单方式是什么_Php_Forms_Email - Fatal编程技术网

Php 将电子邮件从表单发送到gmail帐户的最简单方式是什么

Php 将电子邮件从表单发送到gmail帐户的最简单方式是什么,php,forms,email,Php,Forms,Email,我在一个网站上有一大堆表格,当用户点击提交时,我想把信息发送到我的gmail帐户。下面是我正在使用的代码,但我有问题。当我提交表格时,要么需要很长时间才能收到(比如提交表格后一个小时),要么根本没有收到电子邮件 // Get values from form $customerName =$_POST['name']; $customerPhone =$_POST['phone']; $customerEmail =$_POST['email']; $Year =$_POST

我在一个网站上有一大堆表格,当用户点击提交时,我想把信息发送到我的gmail帐户。下面是我正在使用的代码,但我有问题。当我提交表格时,要么需要很长时间才能收到(比如提交表格后一个小时),要么根本没有收到电子邮件

// Get values from form
$customerName  =$_POST['name'];
$customerPhone =$_POST['phone'];
$customerEmail =$_POST['email'];
$Year          =$_POST['year'];
$Make          =$_POST['make'];
$Model         =$_POST['model'];
$comments      =$_POST['comments'];

$to = "MyGmailAccount@gmail.com";
$subject = "Website Support Form";
$message = "Contact Details \r\n Name: " . $customerName . "\r\n Phone: " . $customerPhone . "\r\n Email: " . $customerEmail . "\r\r Information \r\n Year" . $Year. "\r\n Make: " . $Make . "\r\n Model: " . $Model . "\r\n Problem: " . $comments;

$from = "sendersEmail@whatever.com";
$headers = "From:" . $from . "\r\n";
$headers .= "Content-type: text/plain; charset=UTF-8" . "\r\n"; 

if(@mail($to,$subject,$message,$headers)) {
print "<script>document.location.href='http://www.mywebsite.com/success.php';</script>";
}else{
echo "Error! Please try again.";
{
//从表单中获取值
$customerName=$_POST['name'];
$customerPhone=$_POST['phone'];
$customerEmail=$_POST['email'];
$Year=$_POST['Year'];
$Make=$_POST['Make'];
$Model=$_POST['Model'];
$comments=$_POST['comments'];
$to=”MyGmailAccount@gmail.com";
$subject=“网站支持表格”;
$message=“联系人详细信息\r\n姓名:”$客户名称。“\r\n电话:”$客户电话。“\r\n电子邮件:”$客户邮件。“\r\r信息\r\n年份”$一年。“\r\n Make:”$制作“\r\n模型:”$模型“\r\n问题:”$评论;
$from=”sendersEmail@whatever.com";
$headers=“From:”$从…起“\r\n”;
$headers.=“内容类型:文本/普通;字符集=UTF-8”。“\r\n”;
if(@mail($to,$subject,$message,$headers)){
打印“document.location.href=”http://www.mywebsite.com/success.php';";
}否则{
echo“错误!请重试。”;
{

Slow server,free mail in queue?很难说;Slow traffic,可能是任何东西。黑/灰列表服务器……列表继续…………是的,与代码的关系比服务器、IP或域要小。如果我使用php mailer,它会更快还是同样的原因,它仍然使用相同的服务器?