1

视图.py

follower = FollowerEmail.objects.filter(user=report_id)
list=[]        
for email in follower:
    list.append(email.email)
       ''''''
       ''''''
if 'email' in request.POST:
    subject, from_email, to = 'New Report Created',user.email, person.parent_email
    html_content = render_to_string('report/mail.html',{'person':person,
                                                             'report':report,
                                                             'list':list,
                                                             })
    msg = EmailMultiAlternatives(subject, text_content, from_email, [to],bcc=['list'], cc=['person.email'])
    msg.attach_alternative(html_content, "text/html")
    msg.send()

模型.py

class FollowerEmail(models.Model):
    report = models.ForeignKey(Report)
    email = models.CharField('Email', max_length=100)

我以上述方式尝试过,没有发送电子邮件,在控制台中获得 500s。

如果我将电子邮件地址直接传递给密件抄送字段,邮件正在发送,但我想将电子邮件发送到保存在 FollowerEmail 表中的电子邮件 ID。谁能告诉我该怎么做。

谢谢

4

1 回答 1

1
for email in follower:
    list.append(email)

这不是电子邮件列表,这是人员列表。尝试

list.append(email.email)
于 2013-06-12T17:04:33.750 回答