2016-08-02 4 views
0

boto3 python 라이브러리를 통해 Amazon SES를 테스트하고 있습니다. 이메일을 보낼 때 모든 수신자 주소를 볼 수 있습니다. Amazon SES를 통해 여러 이메일의 ToAddress를 숨기는 방법은 무엇입니까? 다음Amazon SES - 수신자 전자 메일 주소 숨기기

enter image description here

메시지의 메이크업를 세밀하게 제어 할 수 있으므로 우리는 대신 send_raw_email 기능을 사용하는 코드

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

의 일부입니다. 이런 식으로 숨은 참조 헤더를 쉽게 추가 할 수 있습니다.

메시지를 생성하고 그것을

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())