使用php处理程序从HTML表单发送Google Drive电子邮件

时间:2014-10-13 10:55:01

标签: php html email google-drive-api

我在Google云端硬盘上创建了一个文件夹,并将我的css / html / php / images..etc文件放在那里。 当我将浏览器指向www.googledrive.com/host/x时,其中x是文件夹ID,我得到index.html页面。

我要做的是在该页面上有一个表单,用于向我的Gmail帐户发送电子邮件。

这是我正在使用的表格:

<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.";
    }
?>

所以这应该发送两封电子邮件,一封给我,另一封给发件人,并附上一封邮件。

当我填写表单并点击“提交”时,我收到了Google的错误:

“405。那是一个错误。

在此服务器上找不到请求的URL。这就是我们所知道的“

有关为何发生这种情况的任何想法?

1 个答案:

答案 0 :(得分:0)

<?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);
    ?>