Amazon SES - Hide recipient email addresses

时间秒杀一切 提交于 2019-12-12 03:19:40

问题


I am testing Amazon SES through boto3 python library. When i send emails i see all the recipient addresses. How to hide these ToAddresses of multiple email via Amazon SES ?

Following is the part of the code

import boto3
client=boto3.client('ses')
to_addresses=["**@**","**@**","**@**",...]

response = client.send_email(
    Source=source_email,
    Destination={
        'ToAddresses': to_addresses
    },
    Message={
        'Subject': {
        'Data': subject,
        'Charset': encoding
        },
        'Body': {
            'Text': {
                'Data': body ,
                'Charset': encoding
            },
            'Html': {
                'Data': html_text,
                'Charset': encoding
            }
        }
    },
    ReplyToAddresses=reply_to_addresses
)

回答1:


We use the send_raw_email function instead which gives more control over the make up of your message. You could easily add Bcc headers this way.

An example of the code that generates the message and how to send it

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

msg = MIMEMultipart('alternative')
msg['Subject'] = 'Testing BCC'
msg['From'] = 'no-reply@example.com'
msg['To'] = 'user@otherdomain.com'
msg['Bcc'] = 'hidden@otherdomain.com'

We use templating and MIMEText to add the message content (templating part not shown).

part1 = MIMEText(text, 'plain', 'utf-8')
part2 = MIMEText(html, 'html', 'utf-8')
msg.attach(part1)
msg.attach(part2)

Then send using the SES send_raw_email().

ses_conn.send_raw_email(msg.as_string())


来源:https://stackoverflow.com/questions/38722615/amazon-ses-hide-recipient-email-addresses

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!