BotoServerError: 400 Bad Request - While sending email from EC2 Ubuntu instance

BotoServerError: 400 Bad Request - While sending email from EC2 Ubuntu instance

我正在使用部署在 AWS EC2 Ubuntu 实例上的 Django (Pyhton) 框架,并使用 BOTO 和 AWS SES 服务发送电子邮件。 早些时候我的脚本曾经工作过。 但是几天后我遇到了一个错误:

BotoServerError at /contact_us/
BotoServerError: 400 Bad Request
<ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
  <Error>
    <Type>Sender</Type>
    <Code>RequestExpired</Code>
    <Message>Request timestamp: Wed, 16 Mar 2016 16:57:21 GMT expired.  It must be within 300 secs/ of server time.</Message>
  </Error>
  <RequestId>368a4b97-eb97-11e5-bf2d-8ff0675b134d</RequestId>
</ErrorResponse>

Exception Location: /usr/local/lib/python2.7/dist-packages/boto/ses/connection.py in _handle_error, line 177

Server time: Wed, 16 Mar 2016 16:57:21 +0000

SES 正在使用 UTC,我也将 EC2 的时间更改为 UTC。 帮我解决这个问题。

Request timestamp: Wed, 16 Mar 2016 16:57:21 GMT expired. It must be within 300 secs/ of server time.

既然你说几天不工作,那很可能是因为最近的夏令时。很可能你不是 运行 ntp 来同步你的时钟。

试试这个:sudo ntpdate pool.ntp.org

这将同步您的系统时钟。如果您想确保时间同步定期发生,请启动 NTP 守护程序:

sudo service ntp stop
sudo ntpdate -s pool.ntp.org
sudo service ntp start