我已将我的应用程序部署在Google appengine中。用户输入的表单数据通过电子邮件发送给我,我使用Google app引擎提供的邮件api。但是,这似乎工作正常,但是当按下提交按钮时,我连续收到8封邮件,只有一封电子邮件由有效数据组成,其他电子邮件只是没有表单数据。 我还在appengine项目控制台中授权了发件人电子邮件。
这是我的email.php脚本。
<?php
require_once 'google/appengine/api/mail/Message.php';
use google\appengine\api\mail\Message; //line 6 in my code
$name = $_POST['fname'];
$lname = $_POST['lname'];
$email_address = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$textBody= "You have received a new message from your website Name: $name\n\";
$mail_options = [
"sender" => " user@webapp.appspotmail.com",
"to" => "userjow@gmail.com",
"subject" => "You have a new message from your website.",
];
try {
$message = new Message($mail_options);
$message->send();
echo "Thankyou for your Message";
} catch (InvalidArgumentException $e) {
}
?>