Laravel AWS简单电子邮件服务错误SignatureDoesNotMatch(客户端):我们计算的请求签名与您提供的签名不匹配。

时间:2018-06-15 07:13:12

标签: php amazon-web-services email laravel-5.5 amazon-ses

我在laravel 5.5中使用aws ses,当我使用aws ses发送邮件驱动程序时出现如下错误---

Error executing "SendRawEmail" on "https://email.eu-west-1.amazonaws.com"; AWS HTTP error: Client error: `POST https://email.eu-west-1.amazonaws.com` resulted in a `403 Forbidden` response:\n
<ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">\n
  <Error>\n
    <Type>Sender</Type>\n
    <Code>SignatureDo (truncated...)\n
 SignatureDoesNotMatch (client): The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details. - <ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">\n
  <Error>\n
    <Type>Sender</Type>\n
    <Code>SignatureDoesNotMatch</Code>\n
    <Message>The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.</Message>\n
  </Error>\n
  <RequestId>4985867a-7067-11e8-afe4-1b9673bed905</RequestId>\n
</ErrorResponse>\n 

我的控制器:

$sendemail = Mail::send('emails.sendmail',$maildetails,function($message) use($maildetails){
                                                        $message->to($maildetails->email)->subject('Mail Sending process');
                                                  });

我的环境文件:

MAIL_DRIVER=ses
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=****@gmail.com
MAIL_PASSWORD=********
MAIL_ENCRYPTION=tls

SES_ACCESS_KEY =ALKILJUYRTHNFGREDFDSW
SES_ACCESS_SECRET=kjkdcghcbhjghgfrtywuiueiyeuhevgh+cschujhj-jyt
SES_REGION =eu-west-1

我的Service.php文件:

'ses' => [
        'key' => env('SES_ACCESS_KEY'),
        'secret' => env('SES_ACCESS_SECRET'),
        'region' => env('SES_REGION'),
    ],

My Composer.json文件:

"require": {
        "php": ">=7.0.0",
        "aws/aws-sdk-php": "^3.59",
        "fideloper/proxy": "~3.3",
        "guzzlehttp/guzzle": "^6.3",
        "laravel/framework": "5.5.*",
        "laravel/passport": "~4.0",
        "laravel/tinker": "~1.0"

    },

我认为我的配置过程正确,但我不明白为什么它不起作用。如果有人有解决方案......?

1 个答案:

答案 0 :(得分:0)

我假设您已遵循AWS控制台> SES中的“创建我的SMTP凭证”流程(而不是创建IAM用户并手动分配角色/权限)。如果没有,请尝试一下,然后再继续。

下一步,而不是使用ses驱动程序,请尝试smtp

将这些行添加到您的.env文件中应该可以:

MAIL_DRIVER=smtp
MAIL_HOST=email-smtp.us-west-2.amazonaws.com
MAIL_USERNAME="insert_iam_key"
MAIL_PASSWORD="insert_iam_secret"
MAIL_FROM_ADDRESS="no-reply@example.com"

注意:如果SES仍处于沙盒模式(即,您尚未请求提高速率限制),请确保您要发送的域和所发送的电子邮件地址已在AWS控制台> SES中进行了验证。