Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python EmailMultiAlternations不发送密件抄送电子邮件_Python_Django_Email_Django Manage.py_Django Management Command - Fatal编程技术网

Python EmailMultiAlternations不发送密件抄送电子邮件

Python EmailMultiAlternations不发送密件抄送电子邮件,python,django,email,django-manage.py,django-management-command,Python,Django,Email,Django Manage.py,Django Management Command,我有一个Django管理命令,定义如下: class Command(BaseCommand): help = "Sends out an email with new jobs added in a timespan of a week" def handle(self, *args, **options): time_a_week_ago = timezone.now() - timedelta(days=7) time_

我有一个Django管理命令,定义如下:

class Command(BaseCommand):
    help = "Sends out an email with new jobs added in a timespan of a week"

    def handle(self, *args, **options):
        time_a_week_ago = timezone.now() - timedelta(days=7)
        time_now = timezone.now()
        job_listings_added_this_week = JobListing.objects.filter(time_added__gte=time_a_week_ago, time_added__lt=time_now)
        email_subscribers = EmailSubscriber.objects.all()
        emails = []
        for subscriber in email_subscribers:
            emails.append(subscriber.email)
        msg_plain = render_to_string("employers/weekly_newsletter.txt", {"joblistings_list": job_listings_added_this_week})
        msg_html = render_to_string("employers/weekly_newsletter.html", {"joblistings_list": job_listings_added_this_week})

        msg = EmailMultiAlternatives("New jobs added this week", msg_plain, "newsletter@myjobboard.com", [],  bcc=[emails])
        msg.attach_alternative(msg_html, "text/html")
        msg.send()

        self.stdout.write(self.style.SUCCESS("Successfuly sent out the weekly email."))
我将电子邮件内容设置为输出到文件。当我运行管理命令时,我得到的是:

Content-Type: multipart/alternative;
 boundary="===============8145459042862347861=="
MIME-Version: 1.0
Subject: New jobs added this week
From: newsletter@myjobboard.com
Date: Thu, 12 Nov 2020 05:23:05 -0000
Message-ID: 
 <160512424922.55295.17004148678390675586@johns-computer.168.1.22>

--===============8145459042862347861==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

Jobs added last week
Hey! These job listings were added last week:

    Test job 5 - click here: http://127.0.0.1:8000/12/

    Test job 6 - click here: http://127.0.0.1:8000/13/


--===============8145459042862347861==
Content-Type: text/html; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

<h1> Jobs added last week </h1>

    <p> Hey! These job listings were added last week: </p>
    <ul>
    
        <li><a href="http://127.0.0.1:8000/12/">Test job 5</a></li>
    
        <li><a href="http://127.0.0.1:8000/13/">Test job 6</a></li>
    
    </ul>


--===============8145459042862347861==--

-------------------------------------------------------------------------------
内容类型:多部分/备选;
边界=“======================8145459042862347861==”
MIME版本:1.0
主题:本周新增就业岗位
发件人:newsletter@myjobboard.com
日期:2020年11月12日星期四05:23:05-0000
消息ID:
--===============8145459042862347861==
内容类型:文本/纯文本;charset=“utf-8”
MIME版本:1.0
内容传输编码:7bit
上周增加的工作
嘿上周添加了以下工作列表:
测试作业5-单击此处:http://127.0.0.1:8000/12/
测试作业6-单击此处:http://127.0.0.1:8000/13/
--===============8145459042862347861==
内容类型:text/html;charset=“utf-8”
MIME版本:1.0
内容传输编码:7bit
上周增加的工作
嘿!上周添加了以下工作列表:

--===============8145459042862347861==-- -------------------------------------------------------------------------------

在电子邮件标题中,我没有看到密件抄送。为什么呢为什么我的EmailMultiAlternatives不包括密件抄送邮件头?

尝试将
Bcc=[emails]
更改为
Bcc=emails

由于
电子邮件
已经是一个列表,因此不需要额外的方括号