简体   繁体   English

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

[英]Laravel AWS SES - 403 Forbidden - SignatureDoesNotMatch when trying to send email

I'm using the SES Driver "aws/aws-sdk-php" in my Laravel app to send out email via AWS SES(Simple Email Service). 我在Laravel应用程序中使用SES驱动程序"aws/aws-sdk-php"通过AWS SES(简单电子邮件服务)发送电子邮件。

The access key and secret were generated from the SES console > SMTP Settings > Create My SMTP Credentials button. 访问密钥和机密是通过SES控制台> SMTP设置>创建我的SMTP凭据按钮生成的。

The credentials are being saved in the production .env file as such: 凭据将以如下方式保存在生产.env文件中:

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

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

Previously, we already tested with another set of SMTP credentials generated from another AWS account during development, and it works without any issues. 以前,我们已经在开发过程中使用从另一个AWS账户生成的另一组SMTP凭据进行了测试,并且可以正常工作。 Emails are being sent out as expected. 电子邮件已按预期发送。 It even works when using the Keys in a local environment. 当在本地环境中使用按键时,它甚至可以工作。

However, when we are preparing for a production server on another AWS account, the SMTP credentials generated from SES doesn't seem to be working at all, and we are getting the following 403 Forbidden response: 但是,当我们准备在另一个AWS账户上使用生产服务器时,从SES生成的SMTP凭据似乎根本无法正常工作,并且我们收到以下403禁止响应:

[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...)

I tried generating another pair of access keys but still the same. 我尝试生成另一对访问密钥,但仍然相同。

Note that we have successfully verified our domain and Email Address on SES, and tested sending out email from the verified Email Address via the SES console successfully. 请注意,我们已经在SES上成功验证了我们的域和电子邮件地址,并测试了通过SES控制台成功从已验证的电子邮件地址发送电子邮件。

Any help as to what is causing the error is greatly appreciated. 非常感谢有关导致错误的原因的任何帮助。

Solved. 解决了。

I must create an IAM credentials from AWS console instead of SMTP credentials if I'm using SES driver. 如果我使用的是SES驱动程序,则必须从AWS控制台而不是SMTP凭据创建IAM凭据

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

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