base.py 文件源码

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

项目:django-cbmail 作者: dipcode-software 项目源码 文件源码
def send(self, object_or_list):
        """
        Given an object_or_list creates a EmailMultiAlternatives and
        send it to the respective destination.
        If Attachments exist, also adds them to the messsage.
        """
        html_as_string = self.render()
        text_part = strip_tags(html_as_string)

        to = self.get_mail_to(object_or_list)

        if to:
            msg = EmailMultiAlternatives(
                self.get_subject(),
                text_part,
                self.get_mail_from(),
                to=to,
                cc=self.get_mail_cc(),
                bcc=self.get_mail_bcc(),
                reply_to=self.get_mail_reply_to())

            # Attach the html version of email
            msg.attach_alternative(html_as_string, "text/html")

            # If there is attachments attach them to the email
            for attachment in self.get_attachments():
                msg.attach(*attachment.get_triple())

            return get_connection().send_messages([msg])
        return 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号