Reputation: 3368
models.py
class FollowerEmail(models.Model):
report = models.ForeignKey(Report)
email = models.CharField('Email', max_length=100)
views.py
def what(request):
""""""
follower = FollowerEmail.objects.filter(report=report)
list=[]
for email in follower:
list.append(email.email)
""""""""
if 'send_email' in request.POST:
subject, from_email, to = 'Notification',user.email, person.parent_email
html_content = render_to_string('report/print.html',{'person':person,
'report':report,
'list':list,
})
text_content = strip_tags(html_content)
msg = EmailMultiAlternatives(subject, text_content, from_email, [to],bcc=[list], cc=['[email protected]'])
msg.attach_alternative(html_content, "text/html")
msg.send()
The above is my view.py to send email,email is sending to "to" address properlly.Problem is with bcc tag.I am taking the email from FollowerEmail table and making a list.I am passing that list to bcc,as bcc email id list would be large,will be more than 3.
If list is having more than 2 email id,application is not sending mail,if it is two or one,application is sending mail.What could be the problem
Thanks
Upvotes: 0
Views: 67
Reputation: 27861
You have a typo.
list=[]
for email in follower:
list.append(email.email)
At this point list
is already a Python list
(you should probably rename this variable because this is confusing and not a good practice).
Then you use it as:
EmailMultiAlternatives(..., bcc=[list], ...)
And that is where is a typo. You are passing a list with a list item whereas you should be passing just a list of strings:
EmailMultiAlternatives(..., bcc=list, ...)
Upvotes: 1