Python AWS SendRawEmail操作:来自多个收件人的非法地址错误
我有一个AWS Lambda,它使用SES发送电子邮件。当我只有一个收件人时,此函数起作用。但是,只要我向数组中添加2个或更多收件人,它就会失败,并出现以下错误 我在一个沙箱环境中,看到我必须验证发送到的电子邮件域。因此,这不再是一个问题Python AWS SendRawEmail操作:来自多个收件人的非法地址错误,python,amazon-web-services,email,aws-lambda,boto3,Python,Amazon Web Services,Email,Aws Lambda,Boto3,我有一个AWS Lambda,它使用SES发送电子邮件。当我只有一个收件人时,此函数起作用。但是,只要我向数组中添加2个或更多收件人,它就会失败,并出现以下错误 我在一个沙箱环境中,看到我必须验证发送到的电子邮件域。因此,这不再是一个问题 "An error occurred (InvalidParameterValue) when calling the SendRawEmail operation: Illegal address" 我的职责如下: def send_e
"An error occurred (InvalidParameterValue) when calling the SendRawEmail operation: Illegal address"
我的职责如下:
def send_email(sender, recipients, aws_region, subject,url):
client = boto3.client('ses', region_name=aws_region)
BODY_TEXT = "Hi"
BODY_HTML = """\
<H1>Your Results have been process</h1>
<br>
{!s}
</br>
""".format(url)
msg = MIMEMultipart('mixed')
msg['From'] = sender
msg['To'] = ", ".join(recipients)
msg['Subject'] = 'TOI Order Alert'
# The character encoding for the email.
CHARSET = "UTF-8"
msg_body = MIMEMultipart('alternative')
textpart = MIMEText(BODY_TEXT.encode(CHARSET), 'plain', CHARSET)
htmlpart = MIMEText(BODY_HTML.encode(CHARSET), 'html', CHARSET)
# Add the text and HTML parts to the child container.
msg_body.attach(textpart)
msg_body.attach(htmlpart)
# Attach the multipart/alternative child container to the multipart/mixed
# parent container.
msg.attach(msg_body)
# Add the attachment to the parent container.
# msg.attach(att)
# Provide the contents of the email.
response = client.send_raw_email(
Source=msg['From'],
Destinations=[
msg['To']
],
RawMessage={
'Data':msg.as_string(),
}
)
return("Email sent! Message ID:", response['MessageId'])
下面所示的通过收件人对我来说很有用。您可以在代码中尝试相同的方法:
response = client.send_raw_email(
Source=msg['From'],
Destinations= recipients ,
RawMessage={
'Data':msg.as_string(),
}
)
response = client.send_raw_email(
Source=msg['From'],
Destinations= recipients ,
RawMessage={
'Data':msg.as_string(),
}
)