在使用AWS SES CLI时,添加批量联系人时会出现错误。这是因为当前版本的CLI不支持使用JSON或CSV文件添加批量联系人。因此,为了解决这个问题,可以使用以下Python脚本:
import os
import boto3
# Replace with your email address here
FROM_EMAIL_ADDRESS = 'your_email_address@example.com'
# Create an SES client
client = boto3.client('ses')
# Open the file containing email addresses to be added
with open('email_addresses.txt') as f:
email_addresses = f.readlines()
# Strip whitespace and remove empty lines
email_addresses = [x.strip() for x in email_addresses if x.strip()]
# Add each email address to SES
for e in email_addresses:
try:
response = client.verify_email_identity(
EmailAddress=e
)
print(f'{e}: {response["VerificationToken"]}')
except Exception as e:
print(e)
在此脚本中,您需要将您自己的电子邮件地址替换为“FROM_EMAIL_ADDRESS”。然后,您需要创建一个名为“email_addresses.txt”的文本文件,并在其中添加要添加的电子邮件地址。
执行脚本时,使用以下命令:
python add_email_addresses.py
此脚本将逐行读取“email_addresses.txt”文件,并使用AWS SES客户端将每个电子邮件地址添加到您的SES账户中。
希望以上说明能够帮助您解决AWS SES CLI无法添加批量联系人的问题。