from datetime import datetime as dt, timedelta, date
from django.conf import settings
from django.core.mail import send_mail
from django.core.mail import EmailMultiAlternatives
from django.core.management.base import BaseCommand, CommandError
from hive.apps.accounts.sms_utils import send_sms_twilio
to_email = ['[email protected]']
subject = 'Your subject here'
email_body = 'The following clients are currently eligible for Test.Please contact them .<br>'
msg = EmailMultiAlternatives(subject, '', settings.DEFAULT_FROM_EMAIL, to_email)
msg.attach_alternative(email_body, "text/html")
msg.send()
当我与AWS的CentOS运行这段代码instance.i我收到以下错误BotoServerError:400错误的请求:邮件没有发送
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, 01 Oct 2014 07:35:22 GMT expired. It must be within 300 secs/ of server time.</Message>
</Error>
<RequestId>c79a9723-493c-11e4-b2d8-51a7cb197196</RequestId>
</ErrorResponse>
而其另一AWS工作实例。
我已经测试以下可能性。
- 服务器日期和时间。
- 简单的邮件也没有工作: send_mail('你的主题,STR(E),settings.DEFAULT_FROM_EMAIL,fail_email,fail_silently = FALSE)
好错误是说您的电子邮件请求时间戳可能超过5分钟时间漂移?服务器上'date'的输出是什么。 – dreamriver 2014-10-10 04:34:52