[英]Sending mail with PHP application deployed on Google App Engine
我試圖從部署在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.
但是這里沒有安裝他們剛剛指示使用GAE API發送郵件的任何外部應用程序。
我該怎么辦?
我的PHP代碼有問題嗎?
您收到該錯誤是因為您在localhost上運行它,如果您將其部署到您的appengine雲並將“發送自”設置為鏈接到該項目的管理員電子郵件,就像保羅所說的那樣,它應該可以正常運行。 當我使用localhost測試它時,我得到了相同的錯誤,但在部署時,它工作正常。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.