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