저는 파이썬 스크립트를 사용하여 고객과 설문 조사를 통해 이메일을 보냅니다. 숨은 참조 란에 모든 고객의 이메일이 포함 된 이메일을 하나만 보내어 모든 이메일을 반복하지 않아도됩니다. 회사의 동료에게 이메일을 보내고 내 개인 이메일로 보낸 메일을 테스트 할 때 모든 것이 잘 작동하지만 Gmail 계정으로 보낼 때마다 숨은 참조 필드는 숨겨져 있지 않고 모든 이메일을 표시합니다. 나는이 게시물 Email Bcc recipients not hidden using Python smtplib을 발견하고 그 해결책을 시도했지만 html 본문 이메일을 사용함에 따라 이메일이 본문에 표시되었습니다. 아무도 이것에 나를 도울 수 있습니까?BCC가 python smtplib을 사용하여 Gmail에 숨겨져 있지 않습니다.
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
def send_survey_mail():
template_path = 'template.html'
background_path = 'image.png'
button_path = 'image2.png'
try:
body = open(template_path, 'r')
msg = MIMEMultipart()
msg['Subject'] = 'Customer Survey'
msg['To'] = ', '.join(['[email protected]', '[email protected]'])
msg['From'] = '[email protected]'
msg['Bcc'] = '[email protected]'
text = MIMEText(body.read(), 'html')
msg.attach(text)
fp = open(background_path, 'rb')
img = MIMEImage(fp.read())
fp.close()
fp2 = open(button_path, 'rb')
img2 = MIMEImage(fp2.read())
fp2.close()
img.add_header('Content-ID', '<image1>')
msg.attach(img)
img2.add_header('Content-ID', '<image2>')
msg.attach(img2)
s = smtplib.SMTP('smtpserver')
s.sendmail('[email protected]',
['[email protected]', '[email protected]', '[email protected]'],
msg.as_string())
s.quit()
except Exception as ex:
raise ex
send_survey_mail()
코드에서 다음 줄을 제거하고 다시 시도했습니다. 이제 고객의 Gmail 이메일로 이메일이 전송되지 않습니다.
msg['Bcc'] = '[email protected]'
예, 링크를 동일한 솔루션,하지만 내 경우에는 내가, HTML을 수 그래서 그 방법을 수행 이메일 주소를 몸을 필요로했다 제목도 이메일 본문에 표시됩니다. – greenFedoraHat