How to send emails with send_mass_mail in Django for more than one recipients dynamically?


I try to send an email to more than one recipients but I am doing something wrong. I’m using a for loop to get the email addresses from the user. If I print the emails these are in this format: '[email protected]' and I have more than one.
But if I try to send them the email, only one user gets the it.

It sends the mail every time if the html in the is refreshed.

from django.shortcuts import render
from django.core.mail import send_mass_mail
from somemodels.models import Project
import datetime
import calendar

def emails(request):
    today =
    weekday = today.weekday()
    month =
    year =
    cal = calendar.monthrange(year, month)[1]
    firstday =
    message='how are you?'
    from_email='[email protected]'

    for p in Project.objects.raw('SELECT * FROM somemodels_project INNER JOIN auth_user ON = othermodel_project.permitted_users'):
        recipient_list =,

    if (today == firstday):    
        messages = [(subject, message, from_email, [recipient]) for recipient in recipient_list]
        print('Successfully sent')
        print('Not sent') 

    return render(request, 'performance/emails.html')

app_name = 'email'
urlpatterns = [

    path('emails/', login_required(views.emails), name='emails'),



Get the list of people to send the email to

recipient_list =  Project.objects.raw(...)

If your message doesn’t change you can also use

    [ for r in recipient_list],

If you want to use mass mail because it is more efficient

messages = [(subject, message, from_email, []) for r in recipient_list]


Answered By – Nikappa_

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published