Google使用php处理程序从HTML表单驱动电子邮件
我已经在我的谷歌硬盘上创建了一个文件夹,并将我的css/html/php/images..etc文件放在那里。 当我将浏览器指向www.googledrive.com/host/x(其中x是文件夹ID)时,我会看到index.html页面 我想做的是在那个页面上有一个表单,可以向我的gmail帐户发送电子邮件 这是我正在使用的表单:Google使用php处理程序从HTML表单驱动电子邮件,php,html,email,google-drive-api,Php,Html,Email,Google Drive Api,我已经在我的谷歌硬盘上创建了一个文件夹,并将我的css/html/php/images..etc文件放在那里。 当我将浏览器指向www.googledrive.com/host/x(其中x是文件夹ID)时,我会看到index.html页面 我想做的是在那个页面上有一个表单,可以向我的gmail帐户发送电子邮件 这是我正在使用的表单: <title>Form submission</title> <form action="mail_handler.php"
<title>Form submission</title>
<form action="mail_handler.php" method="post">
First Name: <input type="text" name="first_name"><br>
Last Name: <input type="text" name="last_name"><br>
Email: <input type="text" name="email"><br>
Message:<br><textarea rows="5" name="message" cols="30"></textarea><br>
<input type="submit" name="submit" value="Submit">
</form>
我还创建了一个mail_handler.php文件,我在这里的另一篇文章中看到了该文件,其中包含以下内容:
<?php
if(isset($_POST['submit'])){
$to = "myemail@gmail.com";
$from = $_POST['email'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2);
echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
}
?>
因此,应该发送两封电子邮件,一封给我,一封给发件人,并附上一份邮件副本
当我填写表格并点击“提交”时,我从谷歌得到一个错误:
405。那是个错误
在此服务器上找不到请求的URL。我们只知道这些
你知道为什么会发生这种情况吗?对不起,你可以添加一些上下文来说明这是怎么回事吗??代码很模糊,Google drive不支持PHP,你需要把它放在支持PHP的地方。作为旁注,错误405表示“不允许使用方法”,即它不支持POST方法。这是有意义的。谢谢你对免费像样的网络主机有什么建议吗?
<?php
$query=mysql_query(select * from table_name)
$table="";
$table .="<table border='1' style='background-color:#C0C0C0;' >
<tr>
<th bgcolor='#E6E6FA'>Agent Name</th>
<th bgcolor='#E6E6FA'>Count of VOICE - Agent Name</th>
<th bgcolor='#E6E6FA'>Average of Total Time</th>
</tr>";
while($row=mysql_fetch_array($query))
{
$table .="<tr>";
$table .= "<td>" . $row['agent_name'] . "</td>";
$table .= "<td>" . $row['name_count'] . "</td>";
$table .= "<td>" . $row['total_aht'] . "</td>";
}
$table .="</tr>";
$table .= "<tr><td bgcolor='#E6E6FA'>Total</td><td bgcolor='#E6E6FA'>$y</td>
$to = "abc@gmail.com";
$subject="hii";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From:<abc@gmail.com>" . "\r\n";
$mail=mail($to,$subject, $table,$headers);
?>