singhakash
singhakash

Reputation: 7919

Sending mail with PHP application deployed on Google App Engine

I am trying to send email from my PHP application deployed on GAE but unable to send.

My PHP code:

<?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" => "[email protected]",
    "subject" => "Subject",
    "textBody" => $query,
];

try {
    $message = new Message($mail_options);
    $message->send();
} catch (InvalidArgumentException $e) {
    echo "not send";

}?> 

my logs

INFO     2014-07-31 21:40:31,711 mail_stub.py:142] MailService.Send
  From: [email protected]
  To: [email protected]
  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.

But here it is not given to install any external application they just instructed to use GAE API to send mail.

What should I do?

Is there any problem with my PHP code?

Upvotes: 3

Views: 2029

Answers (1)

Gwell
Gwell

Reputation: 281

You are getting that error because you are running it on localhost, if you deploy it to your appengine cloud and set the "send from" to the administrator's email linked to that project like Paul said, it should work. When I tested it with localhost, I got the same error but when deployed, it worked fine.

Upvotes: 4

Related Questions