【问题标题】:How to send an email through AWS simple email service(ses) using signature version 4 in PHP如何使用 PHP 中的签名版本 4 通过 AWS 简单电子邮件服务发送电子邮件
【发布时间】:2020-07-23 00:36:09
【问题描述】:

目前我正在通过 AWS SDK SES 签名 3 发送电子邮件,并收到来自 Amazon 的电子邮件,要求将其升级到 SES 签名版本 4。但是在 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,
                ]
            ]                
        ]);
?>

【问题讨论】:

    标签: php amazon-web-services aws-sdk


    【解决方案1】:

    你可以使用这个包,因为它支持签名 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));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-21
      • 2013-10-10
      • 1970-01-01
      • 2018-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多