繁体   English   中英

如何使用 PHP 中的签名版本 4 通过 AWS 简单 email 服务发送 email

[英]How to send an email through AWS simple email service(ses) using signature version 4 in PHP

Currently I'm sending email through AWS SDK SES signature 3 and got an email from Amazon to upgrade it to SES signature version 4. But where to add signature in AWS SDK? 以下是用于发送电子邮件的当前代码。

<?php
//SES
$SESCredentials = array(
    'key' => awsSESAccessKey,
    'secret' => awsSESSecretKey
);

$SESClient = new SesClient([
    // 'profile' => 'default',
    'version' => AWS_SDK_VERSION,
    'region' => AWS_REGION,
    'http' => [
            'verify' => AWS_CERT_PATH
    ],
    'credentials' => $SESCredentials
]);


$result = $SESClient->sendEmail([
            'Destination' => [
                'ToAddresses' => $recipient_emails
            ],
            'ReplyToAddresses' => [$sender_email],
            'Source' => $sender_email,
            'Message' => [
                'Body' => [
                    'Html' => [
                        'Charset' => $char_set,
                        'Data' => $html_body
                    ]
                ],
                'Subject' => [
                    'Charset' => $char_set,
                    'Data' => $subject,
                ]
            ]                
        ]);
?>

您可以使用此 package,因为它支持签名 4

https://github.com/daniel-zahariev/php-aws-ses

$signature_version = SimpleEmailService::REQUEST_SIGNATURE_V4;
$ses = new SimpleEmailService('AccessKey', 'SecretKey', $region_endpoint, 

$trigger_error, $signature_version);
$m->addTo('Recipient Name <recipient@example.com>');
$m->setFrom('Sender <user@example.com>');
$m->setSubject('Hello, world!');
$m->setMessageFromString('This is the message body.');

$ses = new SimpleEmailService('AccessKey', 'SecretKey');
print_r($ses->sendEmail($m));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM