from django.core.management.base import BaseCommand, CommandError
from letter.models import Letter
from django.utils import timezone
from django.core.mail import send_mass_mail, send_mail


class Command(BaseCommand):
    help = 'Send Email'

    def handle(self, *args, **options):
        letter_list = Letter.objects.filter(destination_time__lte=timezone.
            now(), email_sent='not sent')
        email_list = []
        for letter in letter_list:
            email_list.append((letter.subject, letter.message, letter.user.
                email, [letter.user.email]))
            letter.email_sent = 'sent'
            letter.save()
        send_mass_mail(email_list, fail_silently=False)

d7501d27f2ac83d80782d99ec93ebc5a3c22951b
<mask token>


class Command(BaseCommand):
    <mask token>
    <mask token>

<mask token>


class Command(BaseCommand):
    <mask token>

    def handle(self, *args, **options):
        letter_list = Letter.objects.filter(destination_time__lte=timezone.
            now(), email_sent='not sent')
        email_list = []
        for letter in letter_list:
            email_list.append((letter.subject, letter.message, letter.user.
                email, [letter.user.email]))
            letter.email_sent = 'sent'
            letter.save()
        send_mass_mail(email_list, fail_silently=False)

<mask token>


class Command(BaseCommand):
    help = 'Send Email'

    def handle(self, *args, **options):
        letter_list = Letter.objects.filter(destination_time__lte=timezone.
            now(), email_sent='not sent')
        email_list = []
        for letter in letter_list:
            email_list.append((letter.subject, letter.message, letter.user.
                email, [letter.user.email]))
            letter.email_sent = 'sent'
            letter.save()
        send_mass_mail(email_list, fail_silently=False)

from django.core.management.base import BaseCommand, CommandError
from letter.models import Letter
from django.utils import timezone
from django.core.mail import send_mass_mail, send_mail


class Command(BaseCommand):
    help = 'Send Email'

    def handle(self, *args, **options):
        letter_list = Letter.objects.filter(destination_time__lte=timezone.
            now(), email_sent='not sent')
        email_list = []
        for letter in letter_list:
            email_list.append((letter.subject, letter.message, letter.user.
                email, [letter.user.email]))
            letter.email_sent = 'sent'
            letter.save()
        send_mass_mail(email_list, fail_silently=False)
