我正在尝试从部署在 GAE 上的 PHP 应用程序发送电子邮件,但无法发送。
我的 PHP 代码:
<?php
use google\appengine\api\mail\Message;
$name=$email=$query="";
if($_SERVER["REQUEST_METHOD"]=="POST"){
$name = $_POST["name"];
$email = $_POST["email"];
$query = $_POST["query"];
require_once 'google/appengine/api/mail/Message.php';
$mail_options = [
"sender" => $email,
"to" => "abc@gmail.com",
"subject" => "Subject",
"textBody" => $query,
];
try {
$message = new Message($mail_options);
$message->send();
} catch (InvalidArgumentException $e) {
echo "not send";
}?>
我的日志
INFO 2014-07-31 21:40:31,711 mail_stub.py:142] MailService.Send
From: bca@gmail.com
To: abc0@gmail.com
Subject: Subject
Body:
Content-type: text/plain
Data length: 3
INFO 2014-07-31 21:40:31,711 mail_stub.py:305] You are not currently sending out real email. If you have sendmail installed you can use it by using the server with --enable_sendmail.
但是here没有安装他们刚刚指示使用 GAE API 发送邮件的任何外部应用程序。
我该怎么办?
我的PHP代码有问题吗?
最佳答案
你得到这个错误是因为你在本地主机上运行它,如果你将它部署到你的应用引擎云并将“发送自”设置为管理员的电子邮件链接到该项目,就像保罗说的那样,它应该可以工作。当我使用 localhost 对其进行测试时,我遇到了同样的错误,但在部署时它运行良好。
关于php - 使用部署在 Google App Engine 上的 PHP 应用程序发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25064276/