Php 使用SES发送电子邮件时出现AWS SDK Guzzle错误

Php 使用SES发送电子邮件时出现AWS SDK Guzzle错误,php,email,amazon-web-services,guzzle,Php,Email,Amazon Web Services,Guzzle,我正在尝试使用AWS SES sendEmail方法发送邮件,但遇到错误。我看过这个问题: 我正在处理一个非常类似的问题。原始海报表明他们有解决方案,但没有张贴解决方案 我的代码: $response = $this->sesClient->sendEmail('example@example.com', array('ToAddresses' => array($to)), array('Subject.Data' => array($subject), 'Body

我正在尝试使用AWS SES sendEmail方法发送邮件,但遇到错误。我看过这个问题:

我正在处理一个非常类似的问题。原始海报表明他们有解决方案,但没有张贴解决方案

我的代码:

$response = $this->sesClient->sendEmail('example@example.com', 
array('ToAddresses' => array($to)), 
array('Subject.Data' => array($subject), 'Body.Text.Data' => array($message)));
Guzzle代码产生错误(来自aws/Guzzle/Service/Client.php):

产生的错误:

Catchable fatal error: Argument 2 passed to Guzzle\Service\Client::getCommand() must be of the type array, string given
查看Guzzle代码,我可以看到,如果设置了
args[0]
,则对
getCommand
的调用将发送一个字符串。如果未设置
args[0]
,则发送空数组

请问我在这里遗漏了什么?

解决方案: 事实证明,我试图在SDK2代码库上使用SDK1数据结构。感谢查理·史密斯帮助我理解我做错了什么

对于其他人(使用适用于PHP 2的AWS SDK):

创建客户端-

$this->sesClient = \Aws\Ses\SesClient::factory(array(
    'key'    =>AWS_ACCESS_KEY_ID,
    'secret' => AWS_SECRET_KEY,
    'region' => Region::US_EAST_1
));
现在,构建电子邮件(不要忘记,如果您使用的是沙箱,则需要验证您发送到的任何地址。如果您已被授予生产状态,则此限制不适用)-

$from=“示例名称”;
$to=”example@verified.domain.com";
$subject=“测试AWS SES SendEmail()”;
$response=$this->sesClient->getCommand('sendmail',数组(
“来源”=>$from,
'目标'=>数组(
“ToAddresss”=>数组($to)
),
'消息'=>数组(
“主题”=>数组(
“数据”=>$subject
),
“Body”=>数组(
'文本'=>数组(
“数据”=>“你好,世界!\n正在测试AWS电子邮件发送。”
),
'Html'=>数组(
“数据”=>“你好,世界!正在测试AWS电子邮件发送”

“ ) ), ), ))->执行();
现在应该可以了

以下是AWS SDK for PHP 2文档中的相关部分:

$this->sesClient = \Aws\Ses\SesClient::factory(array(
    'key'    =>AWS_ACCESS_KEY_ID,
    'secret' => AWS_SECRET_KEY,
    'region' => Region::US_EAST_1
));
$from = "Example name <example@example.com>";
$to ="example@verified.domain.com";
$subject = "Testing AWS SES SendEmail()";

$response = $this->sesClient->getCommand('SendEmail', array(
    'Source' => $from,
    'Destination' => array(
        'ToAddresses' => array($to)
    ),
    'Message' => array(
        'Subject' => array(
            'Data' => $subject
        ),
        'Body' => array(
            'Text' => array(
                'Data' => "Hello World!\n Testing AWS email sending."
            ),
            'Html' => array(
                'Data' => "<h1>Hello World!</h1><p>Testing AWS email sending</p>"
            )
        ),
    ),
))->execute();