doulie0178 2018-05-31 15:02
浏览 92
已采纳

Php Mail无法在Google App Engine Flex上运行(未显示错误)

I have a wordpress site running on Google App Engine flex. I'm trying to use the php mail() function for a simple contact form.

I have a block like so:

   if ( mail( $to, $subject, $message, $headers ) ) {
      //stuff
   } else {
      error_reporting(-1);
      ini_set('display_errors', 'On');
      set_error_handler("var_dump");
      var_dump(error_get_last());
      echo '<pre>';
      print_r (error_get_last());
      echo '</pre>';
   }

I've tried using different $from emails with no luck. I get a NULL error message displayed in response. These are settings i'm using. I've tried using my admin @gmail account and now switched to the appsot@gservice. I don't see any mail related items logged in dashboard

$to = 'myemail@gmail.com';
$from = "my-project@appspot.gserviceaccount.com";
$subject = "New Application";
$message = 'test';
$headers  = 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";
$headers .= "From: ".$from."
"."X-Mailer: php";

Keep in mind this is the flex environment. Google only seems to have guides on using third party services for sending bulk email.

this mail function should work right? Do I have to edit my app.yaml or php.ini?

App.yaml

runtime: php
env: flex

manual_scaling:
  instances: 1

handlers:
- url: /(.*\.(htm|html|css|js))$
  static_files: wordpress/\1
  upload: wordpress/.*\.(htm|html|css|js)$
  application_readable: true

- url: /wp-content/(.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg))$
  static_files: wordpress/wp-content/\1
  upload: wordpress/wp-content/.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg)$
  application_readable: true

- url: /(.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg))$
  static_files: wordpress/\1
  upload: wordpress/.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg)$
  application_readable: true

- url: /wp-includes/images/media/(.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg))$
  static_files: wordpress/wp-includes/images/media/\1
  upload: wordpress/wp-includes/images/media/.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg)$
  application_readable: true

- url: /wp-admin/(.+)
  script: wordpress/wp-admin/\1
  secure: always

- url: /wp-admin/
  script: wordpress/wp-admin/index.php
  secure: always

- url: /wp-login.php
  script: wordpress/wp-login.php
  secure: always

- url: /wp-cron.php
  script: wordpress/wp-cron.php
  login: admin

- url: /xmlrpc.php
  script: wordpress/xmlrpc.php

- url: /wp-(.+).php
  script: wordpress/wp-\1.php

- url: /(.+)?/?
  script: wordpress/index.php

beta_settings:
  cloud_sql_instances: myproject-:us-east4:my-instance

runtime_config:
  document_root: wordpress
  skip_lockdown_document_root: true

env_variables:
  WHITELIST_FUNCTIONS: escapeshellarg,escapeshellcmd,exec,pclose,popen,shell_exec,phpversion,php_uname

php.ini

extension=bcmath.so
extension=gd.so
zend_extension=opcache.so
short_open_tag=On
upload_max_filesize = 200M
google_app_engine.disable_readonly_filesystem = 1
  • 写回答

1条回答 默认 最新

  • duan3601 2018-06-01 10:10
    关注

    It is not possible to use App Engine Mail service outside standard environment. I literally cite the official documentation:

    The App Engine Mail service is not available outside the standard environment. You will need to use a third-party mail provider such as SendGrid, Mailgun, or Mailjet to send email. All of these services offer APIs to send email from applications running anywhere.

    The following guides show how to use these services with the flexible environment:

    Sending emails with SendGrid

    Sending emails with Mailgun

    Sending emails with Mailjet

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效