You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

38 lines
1.1 KiB

"""Command for sending the newsletter"""
from django.conf import settings
from django.utils.translation import activate
from django.core.management.base import NoArgsCommand
class Command(NoArgsCommand):
"""Send the newsletter in queue"""
help = 'Send the newsletter in queue'
def handle_noargs(self, **options):
from emencia.django.newsletter.mailer import Mailer
from emencia.django.newsletter.models import Newsletter
verbose = int(options['verbosity'])
if verbose:
print 'Starting sending newsletters...'
activate(settings.LANGUAGE_CODE)
for newsletter in Newsletter.objects.exclude(
status=Newsletter.DRAFT).exclude(status=Newsletter.SENT):
mailer = Mailer(newsletter, verbose=verbose)
if mailer.can_send:
#if verbose:
# with open('/tmp/cron.log', 'a') as f:f.write('Start emailing %s\n' % newsletter.title)
# print 'Start emailing %s' % newsletter.title
mailer.run()
if verbose:
print 'End session sending'