我正在使用 AWS 示例来调用适用于 PHP 的 AWS 开发工具包。将代码转换为函数时,出现以下错误:未捕获错误:调用成员函数 sendEmail()
第 41 行似乎是问题所在: $result = $SesClient->sendEmail([
我尝试删除结果变量并注释掉它的用法
当我运行代码并且它不是一个正常工作的函数时,我不确定我在这里做错了什么,我确信这可能是一个简单的错误。
我在这里先向您的帮助表示感谢
<?php
// If necessary, modify the path in the require statement below to refer to the
// location of your Composer autoload.php file.
require '/vendor/autoload.php';
use Aws\Ses\SesClient;
use Aws\Exception\AwsException;
// Create an SesClient. Change the value of the region parameter if you're
// using an AWS Region other than US West (Oregon). Change the value of the
// profile parameter if you want to use a profile in your credentials file
// other than the default.
$SesClient = new SesClient([
'profile' => 'default',
'version' => '2010-12-01',
'region' => 'us-east-1'
]);
function send_email($recipient, $message, $subject){
// Replace sender@example.com with your "From" address.
// This address must be verified with Amazon SES.
$sender_email = 'sender@gmail.com';
// Replace these sample addresses with the addresses of your recipients. If
// your account is still in the sandbox, these addresses must be verified.
// $recipient_emails = ['recipient1@example.com','recipient2@example.com'];
$recipient_emails = [$recipient];
// Specify a configuration set. If you do not want to use a configuration
// set, comment the following variable, and the
// 'ConfigurationSetName' => $configuration_set argument below.
// $configuration_set = 'ConfigSet';
$subject = $subject;
$plaintext_body = $message.PHP_EOL.'This email was sent with Amazon SES using the AWS SDK for PHP.' ;
$html_body = '<h1>'.$message.'</h1>';
$char_set = 'UTF-8';
翻阅古今
一只名叫tom的猫