Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List 通过Amazon SES向多人发送电子邮件时出现AttributeError_List_Encode_Amazon Ses_Attributeerror - Fatal编程技术网

List 通过Amazon SES向多人发送电子邮件时出现AttributeError

List 通过Amazon SES向多人发送电子邮件时出现AttributeError,list,encode,amazon-ses,attributeerror,List,Encode,Amazon Ses,Attributeerror,我的目标是向多个收件人发送电子邮件。当我在RECIPIENT变量中只发送一封电子邮件并提供Destinations=[RECIPIENT]时,代码会运行,但当我发送多封带有以下代码的电子邮件时,代码会出错 “AttributeError:'列表'对象没有'encode'属性” 任何指点都很感激 RECIPIENT = "abc@xyz.com efg@xyz.com" res = list(RECIPIENT.split(" ")) BODY_TEXT

我的目标是向多个收件人发送电子邮件。当我在RECIPIENT变量中只发送一封电子邮件并提供Destinations=[RECIPIENT]时,代码会运行,但当我发送多封带有以下代码的电子邮件时,代码会出错
“AttributeError:'列表'对象没有'encode'属性” 任何指点都很感激

RECIPIENT = "abc@xyz.com efg@xyz.com"
res = list(RECIPIENT.split(" "))

BODY_TEXT = email_message
client = boto3.client('ses', region_name=region)
# Create a multipart/mixed parent container.
msg = MIMEMultipart('mixed')
# Add subject, from and to lines.
msg['Subject'] = SES_subject
msg['From'] = SENDER
msg['To'] = res

msg_body = MIMEMultipart('alternative')
textpart = MIMEText(BODY_TEXT.encode(CHARSET), 'plain', CHARSET)

# Add the text and HTML parts to the child container.
msg_body.attach(textpart)
msg.attach(msg_body)
if suite_failed_data:
    att = MIMEApplication(open(ATTACHMENT, 'rb').read())
    att.add_header('Content-Disposition', 'attachment', filename=os.path.basename(ATTACHMENT))
    msg.attach(att)

try:
    # Provide the contents of the email.
    response = client.send_raw_email(
        Source=SENDER,
        Destinations=res,
        RawMessage={
            'Data': msg.as_string(),
        },
    )
# Display an error if something goes wrong.
except ClientError as e:
    logger.exception(e)
else:
    logger.info("Email sent!")