谷歌应用程序引擎PHP代码

时间:2016-02-13 04:24:38

标签: email google-app-engine google-app-engine-php

我已在谷歌应用引擎上部署了我的应用程序。用户在表单上输入的输入调用email.php文件(在下面的代码中提到)发送电子邮件。 但是,当我部署它时,当调用php文件(email.php)时,脚本不会被执行,并且脚本将显示在localhost中。 我已经阅读了有关配置app.yaml文件的其他帖子,但它没有帮助。 让我知道必须做些什么。

app.yml

application: shop_app  
version: alpha-001  
runtime: php55  
api_version: 1  
handlers:  
-url: /email.php  
script: assets/email.php      

.php文件

<?php  
  $name = $_POST['fname'];  
  $lname = $_POST['lname'];  
  $email_address = $_POST['email'];  
  $phone = $_POST['phone'];  
  $message = $_POST['message'];  

  // Create the email and send the message  
  $to = 'vikraj@gmail.com'; 
  $email_subject = "Website Contact Form:  $name";  
  $email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nFirst Name: $name\n\nLast Name:$lname\n\nEmail: $email_address\n\nPhone: $phone\n\nMessage:\n\n$message";               
  $headers = "From: userjoe@gmail.com\n"; // This is the email address the generated message will be from. We recommend using something like noreply@yourdomain.com.
   $headers .= "Reply-To: $email_address";    
  mail($to,$email_subject,$email_body,$headers);  

  /* Redirect browser */  
  header("Location: index.html");  
?>

0 个答案:

没有答案