Laravel AWS SES-尝试禁止发送电子邮件时禁止使用403-SignatureDoesNotMatch

时间:2019-07-09 08:57:59

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

我在Laravel应用中使用SES驱动程序"aws/aws-sdk-php"通过AWS SES(简单电子邮件服务)发送电子邮件。

访问密钥和机密是通过SES控制台> SMTP设置>创建我的SMTP凭据按钮生成的。

凭据将按以下方式保存在生产.env文件中:

...
MAIL_FROM_ADDRESS=noreply@example.com
MAIL_FROM_NAME="My Laravel App"

SES_KEY=**********
SES_SECRET=*********
SES_REGION=us-east-1
...

以前,我们已经在开发过程中使用了从另一个AWS账户生成的另一组SMTP凭据进行了测试,并且可以正常工作。电子邮件已按预期发送。甚至在本地环境中使用密钥时,它也可以工作。

但是,当我们准备在另一个AWS账户上使用生产服务器时,从SES生成的SMTP凭据似乎根本无法正常工作,并且我们收到以下 403 Forbidden 响应:

[2019-07-09 16:22:55] production.ERROR: Error executing "SendRawEmail" on "https://email.us-east-1.amazonaws.com"; AWS HTTP error: Client error: `POST https://email.us-east-1.amazonaws.com` resulted in a `403 Forbidden` response:
<ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
  <Error>
    <Type>Sender</Type>
    <Code>SignatureDo (truncated...)
 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/">
  <Error>
    <Type>Sender</Type>
    <Code>SignatureDoesNotMatch</Code>
    <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>
  </Error>
  <RequestId>123abc123-44d3-aa33-vv33-bb1234gg9g1c</RequestId>
</ErrorResponse>
 {"exception":"[object] (Aws\\Ses\\Exception\\SesException(code: 0): Error executing \"SendRawEmail\" on \"https://email.us-east-1.amazonaws.com\"; AWS HTTP error: Client error: `POST https://email.us-east-1.amazonaws.com` resulted in a `403 Forbidden` response:
<ErrorResponse xmlns=\"http://ses.amazonaws.com/doc/2010-12-01/\">
  <Error>
    <Type>Sender</Type>
    <Code>SignatureDo (truncated...)
 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/\">
  <Error>
    <Type>Sender</Type>
    <Code>SignatureDoesNotMatch</Code>
    <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>
  </Error>
  <RequestId>123abc123-44d3-aa33-vv33-bb1234gg9g1c</RequestId>
</ErrorResponse>
 at /var/www/laravel/myapp/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php:191, GuzzleHttp\\Exception\\ClientException(code: 403): Client error: `POST https://email.us-east-1.amazonaws.com` resulted in a `403 Forbidden` response:
<ErrorResponse xmlns=\"http://ses.amazonaws.com/doc/2010-12-01/\">
  <Error>
    <Type>Sender</Type>
    <Code>SignatureDo (truncated...)

我尝试生成另一对访问密钥,但仍然相同。

请注意,我们已经在SES上成功验证了我们的域和电子邮件地址,并测试了通过SES控制台成功地从已验证的电子邮件地址发送电子邮件。

对于引起错误的原因的任何帮助,我们将不胜感激。

1 个答案:

答案 0 :(得分:0)

已解决。

如果我使用的是SES驱动程序,则必须从AWS控制台而不是SMTP凭据创建 IAM凭据