我的代码如下:
def send_email(employee_list):
password = '********'
file = open(os.path.join(path, "html.txt"), "r", encoding="utf8")
source_body = file.read()
file.close()
today = datetime.now().strftime("%d.%m.%Y")
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login('kaan@ttttttt.com', password)
for employee in employee_list:
msg = MIMEMultipart()
msg['From'] = 'noreply@ttttttt.com'
msg['Subject'] = 'Happy new year...'
body = source_body.replace('{{name}}', employee.get('name')).replace('{{anniversary}}',
str(employee.get('diff'))).replace('{{today}}', str(today))
msg['To'] = employee.get('email')
bcc_list = ['kaan@tttttt.com', 'bora@tttttt.com']
if employee.get('manager_email') not in bcc_list:
bcc_list.append(employee.get('manager_email'))
bcc_list = ','.join(bcc_list)
msg.attach(MIMEText(body, 'html'))
server.sendmail(msg['From'], [msg['To']] + bcc_list.split(','), msg.as_string())
server.quit()
我可以将电子邮件发送给所有收件人,但标头中会显示密件抄送收件人。我们如何避免呢?
我什至没有To ['Bcc']对象,但是当我收到电子邮件时,它仍将密件抄送收件人列表显示为密件抄送。
谢谢。