My code is as below:
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()
I can send the e-mail to all recepients but it shows the BCC recepients in the header. How can we avoid it?
I even don't have a To['Bcc'] object but it still shows the bcc_list recepients as bcc when I receive the e-mail.
Thanks.