utils.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:accounts-srv 作者: openpermissions 项目源码 文件源码
def build_mime_text(recipients, subject, message):
    """
    Puts message data into MIME format
    :param recipients: array of email addresses to send email to
    :param subject: subject of email
    :param message: body of email
    :return MIMEMultipart object
    """

    # Record the MIME types of text/plain and text/html.
    part1 = MIMEText(html2text.html2text(message), 'plain')
    part2 = MIMEText(message, 'html')

    # Attach parts into mime message container.
    body = MIMEMultipart('alternative')
    body['Subject'] = subject
    body['From'] = options.smtp_from
    body['To'] = ",".join(recipients)
    body.attach(part1)
    body.attach(part2)

    raise Return(body)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号