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

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

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器