有人可以说明导致这些错误的原因吗?
我在开发服务器上使用Google App Engine。首先我得到了这个错误:
电子邮件未发送。错误消息:执行错误" SendEmail"上 " https://email.us-west-2.amazonaws.com&#34 ;; AWS HTTP错误:没有系统CA. 可以在任何常见系统位置找到捆绑包。 PHP 早于5.6的版本未正确配置为使用 系统的CA捆绑包默认情况下。为了验证对等证书, 您需要将磁盘上的路径提供给证书包 验证'请求选项: http://docs.guzzlephp.org/en/latest/clients.html#verify。如果你不 需要一个特定的证书包,然后Mozilla提供一个常见的 使用的CA捆绑包可以在这里下载(由 cURL的维护者): https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt。 在磁盘上提供CA捆绑包后,您可以设置 ' openssl.cafile' PHP ini设置指向文件的路径, 允许你省略“验证”#39;请求选项。看到 http://curl.haxx.se/docs/sslcerts.html了解更多信息。
然后我将google_app_engine.enable_curl_lite = 1
添加到php.ini并将错误减少到:
电子邮件未发送。错误消息:执行错误" SendEmail" on" https://email.us-west-2.amazonaws.com&#34 ;; AWS HTTP错误:curl_multi_init
我开始明白在GAE上使用SES可能需要一些调整?我该怎么办?
我的代码是来自亚马逊文档的99%。唯一的区别是我在$client
中对凭证数组进行了硬编码。
<?php
// Replace path_to_sdk_inclusion with the path to the SDK as described in
// http://docs.aws.amazon.com/aws-sdk-php/v3/guide/getting-started/basic-usage.html
define('REQUIRED_FILE','../aws/aws-autoloader.php');
// Replace sender@example.com with your "From" address.
// This address must be verified with Amazon SES.
define('SENDER', 'me@verified.sender.address.com');
// Replace recipient@example.com with a "To" address. If your account
// is still in the sandbox, this address must be verified.
define('RECIPIENT', 'me@verified.receiver.address.com');
// Replace us-west-2 with the AWS region you're using for Amazon SES.
define('REGION','us-west-2');
define('SUBJECT','Amazon SES test (AWS SDK for PHP)');
define('BODY','This email was sent with Amazon SES using the AWS SDK for PHP.');
require REQUIRED_FILE;
use Aws\Ses\SesClient;
$client = SesClient::factory(array(
'version'=> 'latest',
'region' => REGION,
'credentials' => array(
'key' => 'xxx',
'secret' => 'xxx',
)
));
$request = array();
$request['Source'] = SENDER;
$request['Destination']['ToAddresses'] = array(RECIPIENT);
$request['Message']['Subject']['Data'] = SUBJECT;
$request['Message']['Body']['Text']['Data'] = BODY;
try {
$result = $client->sendEmail($request);
$messageId = $result->get('MessageId');
echo("Email sent! Message ID: $messageId"."\n");
} catch (Exception $e) {
echo("The email was not sent. Error message: ");
echo($e->getMessage()."\n");
}
?>
修改
部署完成后,无需对php.ini进行任何编辑...... ??