问题
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