Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 830
singhakash Avatar asked May 10 '26 07:05

singhakash


1 Answers

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.

like image 150
Gwell Avatar answered May 12 '26 00:05

Gwell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!