在我的Bluemix应用程序上提交按钮不再工作(错误500)

时间:2017-03-20 22:38:43

标签: php ibm-cloud form-submit sendgrid http-status-code-500

我的应用程序工作正常整整一个月,但是在03/17(上周)之后,我在点击提交按钮后不断收到此错误消息(我的应用程序发送一封电子邮件,其中包含表单上的详细信息)使用SendGrid)。 单击“提交”按钮后,Chrome上的错误消息:

myapp.mybluemix.net is currently unable to handle this request.
HTTP ERROR 500

问题是我不记得改变任何重大内容(我甚至尝试过我的应用程序的旧版本但仍然没有工作),但它看起来像是Bluemix问题,因为它有效在当地很好。

这是我的日志与" cf log"命令:

2017-03-20T19:24:55.65-0300 [APP/0]      OUT 22:24:55 httpd   | 169.54.180.77 -
- [20/Mar/2017:22:24:55 +0000] "POST /index.php HTTP/1.1" 500 - vcap_request_id=
682b55c0-a427-4984-78e5-3d192c613352 peer_addr=169.54.180.77
2017-03-20T19:24:55.65-0300 [APP/0]      OUT 22:24:55 httpd   | [Mon Mar 20 22:2
4:55.598001 2017] [proxy_fcgi:error] [pid 47:tid 140581812508416] [client 169.54
.180.77:48798] AH01071: Got error 'PHP message: PHP Fatal error:  Uncaught Error
: Call to undefined function SendGrid\\mb_convert_encoding() in /home/vcap/app/l
ib/vendor/sendgrid/sendgrid/lib/helpers/mail/Mail.php:744\nStack trace:\n#0 /hom
e/vcap/app/htdocs/index.php(129): SendGrid\\Content->__construct('text/plain', '
%PROPERTY={{Req...')\n#1 {main}\n  thrown in /home/vcap/app/lib/vendor/sendgrid/
sendgrid/lib/helpers/mail/Mail.php on line 744\n', referer: http://myapp.
mybluemix.net/index.php

我不确定如何解释此错误,请帮忙!

这是我的代码:

// If there are no errors, send the email
if (!$errName && !$errEmail && !$errMessage && !$errHuman) {
    $message = $sdrmsg;
require 'vendor/autoload.php';
// If you are not using Composer
// require("path/to/sendgrid-php/sendgrid-php.php");
$from = new SendGrid\Email("", "$email");
$subject = "REQUEST";
$to = new SendGrid\Email("email", "email@example.com");
$content = new SendGrid\Content("text/plain", $message);
$mail = new SendGrid\Mail($from, $subject, $to, $content);
$apiKey = 'mykey';
$sg = new \SendGrid($apiKey);
$response = $sg->client->mail()->send()->post($mail);
echo $response->body();
}

1 个答案:

答案 0 :(得分:1)

错误是 - PHP消息:PHP致命错误:未捕获错误:调用未定义函数SendGrid \ mb_convert_encoding()

分辨率: 您必须在服务器中启用mb_string。你在用php_buildpack吗?

mbstring是php buildpack的受支持扩展,但必须明确启用。

您可以按照此回答解决错误https://developer.ibm.com/answers/questions/179545/how-to-enable-mbstring-extension-in-php-buildpack.html