2016-08-02 81 views
0

我正在通過boto3 python庫測試Amazon SES。當我發送電子郵件時,我會看到所有收件人地址。如何通過Amazon SES隱藏多個電子郵件的地址?Amazon SES - 隱藏收件人電子郵件地址

enter image description here

以下是代碼

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

發送他們作爲BCC而不是一個? –

+0

從內存中,它不會讓你以這種方式執行BCC,你需要自己創建一個消息併發送原始數據。見下面的答案。 – mouckatron

+0

SES是[每個收件人收費](https://aws.amazon.com/ses/pricing/),而不是每個消息...所以如果您出於成本原因將同一消息發送給多個收件人,噸。 –

回答

0

我們使用send_raw_email功能,而不是賦予了你的信息彌補更多的控制權的一部分。您可以通過這種方式輕鬆添加Bcc標題。

生成該消息以及如何發送它

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

msg = MIMEMultipart('alternative') 
msg['Subject'] = 'Testing BCC' 
msg['From'] = '[email protected]' 
msg['To'] = '[email protected]' 
msg['Bcc'] = '[email protected]' 

我們使用模板和MimeText用於要添加的消息內容(模板部分未示出)的代碼的一個例子。

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

然後使用SES send_raw_email()發送。

ses_conn.send_raw_email(msg.as_string()) 
相關問題