【问题标题】:How to fix PHP error from file ApplicationError.php for sending emails如何从文件 ApplicationError.php 中修复 PHP 错误以发送电子邮件
【发布时间】:2014-02-09 07:56:14
【问题描述】:

我正在尝试使用来自 Google App Engine 的 PHP 发送电子邮件。要发送电子邮件,Require Once 必须包含 php 文件 Message.php:请参阅:Code example here at Google

require_once 'google\appengine\api\mail\Message.php';

Message.php 文件包括:

require_once 'google/appengine/api/mail/BaseMessage.php';

BaseMessage.php 文件又需要另外三个 PHP 文件:

require_once 'google/appengine/api/mail_service_pb.php';
require_once 'google/appengine/runtime/ApiProxy.php';
require_once 'google/appengine/runtime/ApplicationError.php';

所以,回顾一下,Message.php 需要 BaseMessage.phpBaseMessage.php 需要另外 3 个 php 文件。

在需要最后一个 PHP 文件之前一切正常:

require_once 'google/appengine/runtime/ApplicationError.php';

然后发生致命错误:

Fatal error: Class 'google\appengine\runtime\Error' not found in
C:\Users\UserName\Dropbox\ApplicationName\google\appengine\runtime\
ApplicationError.php on line 22

这是第 22 行:

class ApplicationError extends Error {

这是由 Google 提供的代码:the latest PHP SDK for App Engine

这不是我写的代码。所需文件的路径似乎有效,否则我会在第一个所需文件上收到错误消息。我已经测试了 require_once 引用同一目录中其他 PHP 文件的代码行,没有错误。所以问题不是相对路径或 PHP.ini 文件的问题。

我的 PHP 版本是Current PHP version: 5.4.22 Windows 7的 XAMPP 与 Netbeans、Apache

我该如何解决这个问题?

【问题讨论】:

  • 最新的 sdk 具有自动加载功能 - 您不需要对任何 SDK 功能使用 require/include。
  • Google 的示例代码使用require。我愿意使用我可以开始工作的任何代码。因此,如果有人能指出我的代码和可行的配置,我将不胜感激。

标签: php google-app-engine email


【解决方案1】:

我得到了 PHP 电子邮件代码的工作。我仍然不知道确切的问题是什么,但它必须与我的 Netbeans IDE 当前配置为 PHP 的方式有关。 Google App Engine SDK 在其安装中内置了 PHP,但我没有从 Google App Engine Launcher 运行我的应用程序。当我直接从 Google App Engine Launcher 运行我的应用程序时,代码可以正常工作。我猜 PHP 的 Netbeans 版本与 PHP 的 Google App Engine SDK 版本有点不同。这导致其中一个文件出错。无论如何,我得到了发送电子邮件上班的 PHP 代码。因此,代码将运行。这告诉我,我在 Netbeans 中对 PHP 的配置可能与在 Google App Engine SDK 中的 PHP 版本中对 PHP 的配置不同。我可能会尝试调整 netbeans 中的 PHP.ini 文件,看看是否可以直接链接到 PHP 的 Google App Engine SDK 版本。

【讨论】:

    猜你喜欢
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    • 2014-09-08
    • 1970-01-01
    • 2017-01-16
    • 1970-01-01
    • 2014-04-12
    • 1970-01-01
    相关资源
    最近更新 更多