无法在电子邮件标题中添加抄送:字段

时间:2019-07-17 06:38:48

标签: python email mime smtplib email-headers

我无法在标题中添加抄送字段。

我正在使用邮件客户端处理python,并希望发送带有标头的邮件,但是我无法在此处添加cc,请帮忙。

try:
    client.sendmail(sender, receivers, _make_mime(sender,receivers, subject, content, attachments).as_string())

def _make_mime(mail_from, mail_to, subject, body, attachments):
    '''create MIME'''
    msg = MIMEMultipart()
    msg['From'] = Header(mail_from, 'ascii')
    msg['To'] = Header(mail_to,  'ascii')
    msg['Subject'] = Header(subject, 'ascii')
    msg.preamble = 'You will not see this in a MIME-aware mail reader.\n'
    msg.attach( MIMEText(body,'plain'))
    for filepath in attachments:
        msg.attach(_get_attach_msg(filepath))
    return msg

def send_email(sender,receivers, subject, content, attachments, smtp_host, smtp_user, smtp_passwd):
    client.sendmail(sender, receivers, _make_mime(sender,receivers, subject, content, attachments).as_string())  

0 个答案:

没有答案