1
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)
我尝试了以上述方式,没有电子邮件被发送,让控制台500S。
如果我直接传递一个电子邮件地址,以密件抄送字段,邮件发送,但我想发送电子邮件到保存在FollowerEmail电子邮件ID table.Can谁能告诉我如何做到这一点。
感谢
你能提供异常的任何回溯? –
您的代码中有语法错误。 'if'块向左缩进一级。 – karthikr