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 ) ) {
   } else {
      ini_set('display_errors', 'On');
      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 = '';
$from = "";
$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?


runtime: php
env: flex

  instances: 1

- 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

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

  document_root: wordpress
  skip_lockdown_document_root: true

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

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

    解决 无用
    打赏 举报

相关推荐 更多相似问题