【发布时间】:2019-05-10 15:47:22
【问题描述】:
我正在尝试使用 django-ses 库从 django 发送电子邮件但收到错误:
boto.exception.BotoServerError: BotoServerError: 403 Forbidden
<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>7e2103e0-729f-11a9-aq25-51a2dqa8ae97</RequestId>
</ErrorResponse>
我在 AWS 控制台中验证了域并验证了管理员地址 admin@...com 地址,并从 SES 控制面板创建了 API 密钥和密钥。
Django 设置:
EMAIL_BACKEND = 'django_ses.SESBackend'
AWS_SES_ACCESS_KEY_ID = os.environ.get('AWS_SES_ACCESS_KEY_ID')
AWS_SES_SECRET_ACCESS_KEY = os.environ.get('AWS_SES_SECRET_ACCESS_KEY')
AWS_SES_REGION_NAME = 'eu-west-1' # because I use ireland server, but same error without this
SERVER_EMAIL = 'admin@...com'
DEFAULT_FROM_EMAIL = '"Hello You" <no-reply@...com>'
我尝试发送电子邮件:
from django.core.mail import EmailMessage
from django.conf import settings
email = EmailMessage(
'Hello',
'World',
settings.DEFAULT_FROM_EMAIL,
to=['mail@example.com']
)
email.send()
这里有什么问题?
【问题讨论】:
标签: python django amazon-ses django-ses