티스토리 뷰

공부

[Python] smtplib (with BCC)

seunggabi 승가비 2021. 7. 25. 00:00
def send(to, cc, bcc, subject, text, html):
    message = MIMEMultipart("alternative")
    message["Subject"] = subject
    message["From"] = MAIL_FROM
    message["To"] = to
    message["Cc"] = cc + "," + MAIL_DL

    if html is not None:
        body = MIMEText(html, "html")
    else:
        body = MIMEText(text)
    message.attach(body)

    server = smtplib.SMTP(MAIL_SERVER)
    server.set_debuglevel(1)

    server.sendmail(MAIL_DL, to.split(",") + bcc.split(","), message.as_string())
    server.quit()

    return {
        "to": to,
        "cc": cc,
        "bcc": bcc,
        "subject": subject,
        "text": text,
        "html": html,
    }

https://stackoverflow.com/questions/43017496/bcc-not-hidden-on-gmail-using-python-smtplib/68511164#68511164

 

BCC not hidden on gmail using python smtplib

I am working on a python script to send email to my customer with a survey. I will send only one email with all my customers's emails in the BCC field so that I do not need to loop through all the ...

stackoverflow.com

 

'공부' 카테고리의 다른 글

[Python] string format range text  (0) 2021.07.25
[Linux] overwrite symbolic link  (0) 2021.07.25
[Python] smtplib (with BCC)  (0) 2021.07.25
[SQL] UNION(DISTINCT) & UNION ALL  (0) 2021.07.24
[Java] cast object by generic  (0) 2021.07.24
[Linux] clear kerberos (kdestroy)  (0) 2021.07.24
댓글
댓글쓰기 폼