我想使用亚马逊的简单电子邮件服务发送电子邮件。
我验证了我的域名以及我想发送的电子邮件地址。
两者都显示已核实。
现在,当我从AWS控制台使用发送测试电子邮件向myemail@outlook.com发送测试电子邮件时,我只得到错误消息:
电子邮件地址未验证。下面的标识失败了
check in region EU-WEST-1: myemail@outlook.com(请求ID:
9 fb78de1 - 2673 - 11 - e6 bbbc - 5 - f819fabe4f4)
现在它让我震惊,因为它说myemail@outlook.com没有经过验证,但我试图从admin@mydomain.example发送。发送测试电子邮件对话框甚至强迫您使用已经注册的电子邮件。
如何解决这个问题?我错过什么了吗?
我有这个问题。我验证了域名和电子邮件,甚至DKIM设置也得到了验证。
但还是得到了这样的信息:
Email address is not verified. The following identities failed the check in region {aws_region}: {email}
我添加了SourceArn作为sendEmail的参数,然后得到这条消息:
User `arn:aws:iam::{account_id}:user/{username}' is not authorized to perform `ses:SendEmail' on resource `arn:aws:ses:{aws_region:{account_id}:identity/{email}'
2天后,我发现我使用了错误的IAM用户!
几分钟前我遇到了同样的问题,尽管这次我使用的是PHP SDK。
我必须再次检查SesClient实例化代码。
$SesClient = new SesClient([
'profile' => 'default',
'version' => '2010-12-01',
'region' => 'us-west-2',
]);
我发现实例化代码中的区域是us-west-2。
我回到我的控制台,发现SES帐户被沙盒在us-east-2(俄亥俄州)。
我在实例化代码中实现了这样的更改
$SesClient = new SesClient([
'profile' => 'default',
'version' => '2010-12-01',
'region' => 'us-east-2',
]);
现在起作用了。
问题
混淆来自于这样一个事实,即您的电子邮件地址在AWS SES ->中显示为“已验证”,但仍不能工作。
其实有两种验证:
DKIM一(使田野标记绿色并验证)
电子邮件地址验证
这意味着您必须使用您可以访问的电子邮件地址(邮箱)才能单击验证链接。
如果不单击电子邮件中的链接,您的身份可能会得到验证,但仍然会到处看到错误。
使用AWS WorkMail的简单解决方案
我正在使用AWS WorkMail,但我已经创建了一个新组,而不是另一个WorkMail帐户,然后将我的个人帐户添加到其中,收到一封验证电子邮件,并设法获得:“noreply@...”工作。
在我的情况下,我想发送电子邮件到相同的验证电子邮件。
所以,我验证了我的邮件是DKIM @Greg Wozniak写的。我看到了绿色的标记,并验证了:
但我仍然看到:
Email address is not verified. The following identities failed the check in region...
在我的情况下,解决方案是在代码中添加这个函数:
def verify_email_identity():
ses_client = boto3.client("ses", region_name="us-east-1")
response = ses_client.verify_email_identity(
# Email address that will receive the email
# In my case the same email address
# that was verified on Amazon SES
EmailAddress="receipientemail@gmail.com"
)
print(response)
从这个网站上截取
所以,我收到了一封新的邮件来验证收件人的邮箱地址。确认收件人邮箱地址后,点击亚马逊SES发送的链接。我可以用这个代码发送邮件:
client = boto3.client('ses',region_name="us-east-1")
# Try to send the email.
try:
#Provide the contents of the email.
response = client.send_email(
Destination={
'ToAddresses': [
receipientemail@gmail.com,
],
},
Message={
'Body': {
'Html': {
'Charset': "UTF-8",
'Data': "Test",
},
},
'Subject': {
'Charset': "UTF-8",
'Data': "Test",
},
},
Source=receipientemail@gmail.com,
)
# Display an error if something goes wrong.
except ClientError as e:
print(e.response['Error']['Message'])
else:
print("Email sent! Message ID:"),
print(response['MessageId'])