Django admin action with intermediate page processes only first 100 of selection

Viewed 105

I have an admin action where I select artists and then choose an email which I want to sent them. If I filter the artists and then choose select all, I get around 1000 artist. If I sent the email, its only send to the first 100.

This is my action:

def send_email(self, request, queryset):
    form = None

    if 'apply' in request.POST:
        form = ChooseEmailForm(request.POST)

        if form.is_valid():
            email = form.cleaned_data['email']

            htmlMessage = email.htmlMessage
            for artist in queryset:
                send_single_email(email, artist)
            
            self.message_user(request, _('Successfully emailed \'%s\' to the selected artists.') % (email))
            return HttpResponseRedirect(request.get_full_path())

    if not form:
        form = ChooseEmailForm(initial={'_selected_action': request.POST.getlist(ACTION_CHECKBOX_NAME)})

    return render(request, 'admin/send_email.html', {'artists': queryset, 'email_form': form})

This is my form:

class ChooseEmailForm(forms.Form):
    _selected_action = forms.CharField(widget=forms.MultipleHiddenInput)
    email = forms.ModelChoiceField(queryset=Email.objects.all(), label='')

and this is my html:

{% extends "admin/base_site.html" %}

{% block content %}

<p>Select the email to send:</p>

<form action="" method="post">
    {% csrf_token %}

    {{ email_form }}

    <p>De chosen email will be send to the following artists:</p>

    <ul>{{ artists|unordered_list }}</ul>

    <input type="hidden" name="action" value="send_email" />
    <input type="submit" name="apply" value="Send email" />
</form>

{% endblock %}

On the intermediate form it says: 'De chosen email will be send to the following artists:' and lists all 1000 artists. But when I apply, it's only send to the first 100.

Any ideas?

1 Answers

I think that it is linked to the mail manager that you use in the project.

I guess that it's Gmail !

According to Gmail sending limits in Google Workspace, recipients per message sent via SMTP (by POP or IMAP users) or the Gmail API is limited to 100 ( Addresses in the To, Cc, and Bcc fields of a single email. Includes email sent using smtp-relay.gmail.com or smtp.gmail.com ).

I think that, it is the issue ( if Gmail of course ).

Related