Amazon SES-隐藏收件人电子邮件地址 [英] Amazon SES - Hide recipient email addresses

查看:250
本文介绍了Amazon SES-隐藏收件人电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过boto3 python库测试Amazon SES.当我发送电子邮件时,我会看到所有收件人的地址.如何通过Amazon SES隐藏多个电子邮件的这些ToAddresses?

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 ?

以下是代码的一部分

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
)

推荐答案

我们改用send_raw_email函数,该函数可以更好地控制邮件的组成.您可以通过这种方式轻松添加密件抄送标题.

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'

我们使用模板和MIMEText添加消息内容(模板部分未显示).

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)

然后使用SES send_raw_email()发送.

Then send using the SES send_raw_email().

ses_conn.send_raw_email(msg.as_string())

这篇关于Amazon SES-隐藏收件人电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆