我在Google App Engine flex上运行了一个wordpress网站。我正在尝试将php mail()函数用于简单的联系表单。
我有一个像这样的块:
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>';
}
我尝试过使用电子邮件中的不同$而没有运气。我收到响应中显示的NULL错误消息。这些是我正在使用的设置。我已经尝试使用我的admin @gmail帐户,现在切换到appsot @ gservice。我没有在仪表板中看到任何与邮件相关的项目
$to = 'myemail@gmail.com';
$from = "my-project@appspot.gserviceaccount.com";
$subject = "New Application";
$message = 'test';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: ".$from."\r\n"."X-Mailer: php";
请记住这是灵活环境。谷歌似乎只有使用第三方服务发送批量电子邮件的指南。
这个邮件功能应该正常吗?我是否必须编辑app.yaml或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
答案 0 :(得分:1)
在标准环境之外无法使用App Engine邮件服务。我确实引用了official documentation:
App Engine邮件服务在标准之外不可用 环境。您将需要使用第三方邮件提供商,例如 SendGrid,Mailgun或Mailjet发送电子邮件。所有的 这些服务提供API以从运行的应用程序发送电子邮件 任何地方。
以下指南介绍了如何灵活使用这些服务 环境: