views.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()
models.py
class FollowerEmail(models.Model):
report = models.ForeignKey(Report)
email = models.CharField('Email', max_length=100)
我以上述方式尝试过,没有发送电子邮件,在控制台中获得500个。
如果我直接将电子邮件地址传递给密件抄送字段,邮件正在发送,但我想将电子邮件发送到FollowerEmail表中保存的电子邮件ID。任何人都可以告诉我如何执行此操作。
谢谢
答案 0 :(得分:1)
for email in follower:
list.append(email)
这不是电子邮件列表,而是人员列表。尝试
list.append(email.email)