Esempio n. 1
0
 def send_mail_test(self, request, queryset):
     """Send newsletter in test"""
     for newsletter in queryset:
         if newsletter.test_contacts.count():
             mailer = Mailer(newsletter, test=True)
             try:
                 mailer.run()
             except HTMLParseError:
                 self.message_user(request, _('Unable send newsletter, due to errors within HTML.'))
                 continue
             self.message_user(request, _('%s succesfully sent.') % newsletter)
         else:
             self.message_user(request, _('No test contacts assigned for %s.') % newsletter)
    def handle_noargs(self, **options):
        verbose = int(options['verbosity'])

        if verbose:
            print 'Starting sending newsletters...'

        for newsletter in Newsletter.objects.exclude(
            status=Newsletter.DRAFT).exclude(status=Newsletter.SENT):
            mailer = Mailer(newsletter)
            if mailer.can_send:
                if verbose:
                    print 'Start emailing %s' % newsletter.title
                mailer.run()

        if verbose:
            print 'End session sending'