6👍
battery’s answer is ok, but i would do this way:
recievers = []
for user in Users.objects.all():
recievers.append(user.email)
send_mail(subject, message, from_email, recievers)
this way, you will open only once connection to mail server rather than opening for each email.
0👍
Sending email is very simple.
For your Users
model this would be:
for user in Users.objects.all():
send_mail(subject, message, from_email,
user.Email)
Checkout Django’s Documentation on send emails for more details.
Would be useful if you mention what problem you are facing if you’ve tried this.
Also note, IntegerField
does not have a max_length
argument.
- [Django]-How can I disable some options in the Select widget of a mptt's TreeForeignKey field in some model admin?
- [Django]-Python / Django – Exception Value: 'WSGIRequest' object has no attribute 'Meta'
- [Django]-Help with complex join in Django ORM
- [Django]-Trouble with Django unnecessarily adding 5 hours to date time.
-1👍
for user in Users.objects.all():
send_mail(subject, message, from_email,
user.Email)
This is the best solutions and it works well
- [Django]-Sharing session between different application platforms
- [Django]-I/O operation on closed file in django with 'ImageKit'
- [Django]-Django: raw passwords via request.POST
- [Django]-Elegant rotating logging filename in django
- [Django]-Django template: How can I regroup a list of dictionaries by a nested property of each dictionary?
Source:stackexchange.com