Python django.conf.settings 模块,ADMINS 实例源码

我们从Python开源项目中,提取了以下44个代码示例,用于说明如何使用django.conf.settings.ADMINS

项目:modeltranslation    作者:intelligenia    | 项目源码 | 文件源码
def export_translations(request, language):
    """
    Vista de exportación de las traducciones
    """
    FieldTranslation.delete_orphan_translations()
    translations = FieldTranslation.objects.filter(lang=language)
    for trans in translations:
        trans.source_text = trans.source_text.replace("'","\'").replace("\"","\\\"")
        trans.translation = trans.translation.replace("'","\'").replace("\"","\\\"")
    replacements = {"translations":translations, "lang":language}
    if len(settings.ADMINS)>0:
        replacements["last_translator"] = settings.ADMINS[0][0]
        replacements["last_translator_email"] = settings.ADMINS[0][1]
    if settings.WEBSITE_NAME:
        replacements["website_name"] = settings.WEBSITE_NAME
    response = render(request=request, template_name='modeltranslation/admin/export_translations.po', dictionary=replacements, context_instance=RequestContext(request), content_type="text/x-gettext-translation")
    response['Content-Disposition'] = 'attachment; filename="{0}.po"'.format(language)
    return response


########################################################################
########################################################################
## Actualizar las traducciones
项目:modeltranslation    作者:intelligenia    | 项目源码 | 文件源码
def export_translations(request, language):
    """
    Export translations view.
    """
    FieldTranslation.delete_orphan_translations()
    translations = FieldTranslation.objects.filter(lang=language)
    for trans in translations:
        trans.source_text = trans.source_text.replace("'","\'").replace("\"","\\\"")
        trans.translation = trans.translation.replace("'","\'").replace("\"","\\\"")
    replacements = {"translations":translations, "lang":language}
    if len(settings.ADMINS)>0:
        replacements["last_translator"] = settings.ADMINS[0][0]
        replacements["last_translator_email"] = settings.ADMINS[0][1]
    if settings.WEBSITE_NAME:
        replacements["website_name"] = settings.WEBSITE_NAME
    response = render(request=request, template_name='modeltranslation/admin/export_translations.po', dictionary=replacements, context_instance=RequestContext(request), content_type="text/x-gettext-translation")
    response['Content-Disposition'] = 'attachment; filename="{0}.po"'.format(language)
    return response


########################################################################
########################################################################
## Update translations
项目:MovieScheduler    作者:rubysoho07    | 项目源码 | 文件源码
def send_error_report(url, exception, trace):
    """Send email when an error occurs."""
    if settings.DEBUG is False:
        email_context = {
            'site': url,
            'exception': exception,
            'traceback': trace
        }
        message = get_template('scheduler_core/error_report_parsing.html').render(email_context)
        error_email = EmailMessage('[MovieScheduler] Parsing Error Report',
                                   message,
                                   settings.SERVER_EMAIL,
                                   settings.ADMINS)
        error_email.content_subtype = 'html'
        error_email.send(fail_silently=False)
    else:
        print("Exception: " + str(exception))
        print("Traceback: ")
        print(trace)
项目:trunk-player    作者:ScanOC    | 项目源码 | 文件源码
def create_profile(sender, **kwargs):
    user = kwargs["instance"]
    if kwargs["created"]:
        default_plan = Plan.objects.get(pk=Plan.DEFAULT_PK)
        up = Profile(user=user, plan=default_plan)
        up.save()
        try:
            for tg in TalkGroupAccess.objects.filter(default_group=True):
                up.talkgroup_access.add(tg)
        except OperationalError:
            pass
        try:
            new_user_email = SiteOption.objects.get(name='SEND_ADMIN_EMAIL_ON_NEW_USER')
            if new_user_email.value_boolean_or_string() == True:
                send_mail(
                      'New {} User {}'.format(settings.SITE_TITLE, user.username),
                      'New User {} {} Username {} Email {} just registered'.format(user.first_name, user.last_name, user.username, user.email),
                      settings.SERVER_EMAIL,
                      [ mail for name, mail in settings.ADMINS],
                      fail_silently=False,
                     )
        except (SiteOption.DoesNotExist, OperationalError):
            pass
项目:mes    作者:osess    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, priority="medium"):
    from django.utils.encoding import force_unicode
    from django.conf import settings
    from mailer.models import Message

    priority = PRIORITY_MAPPING[priority]

    subject = settings.EMAIL_SUBJECT_PREFIX + force_unicode(subject)
    message = force_unicode(message)

    if len(subject) > 100:
        subject = u"%s..." % subject[:97]

    for name, to_address in settings.ADMINS:
        Message(to_address=to_address,
                from_address=settings.SERVER_EMAIL,
                subject=subject,
                message_body=message,
                priority=priority).save()
项目:openbare    作者:openbare    | 项目源码 | 文件源码
def request_extension(request, primary_key):
    """Send email to admins to request :model:`library.Lendable` extension.

    After renewing a lendable the max available (max_renewals) times
    a user may request an extension. An email is sent to the site
    ADMINS as found in the settings for this request.

    Redirect:
    :view:`library.index`
    """
    admin_path_for_lendable = reverse(
        'admin:library_lendable_change',
        args=(primary_key,)
    )
    admin_url_for_lendable = settings.PRIMARY_URL + admin_path_for_lendable
    try:
        send_mail(
            'openbare: request to extend due_date of PK#%s' % primary_key,
            'Message from %s:\n%s\n\n%s' % (
                request.user.username,
                request.POST['message'],
                admin_url_for_lendable
            ),
            request.user.email,
            _admin_emails()
        )
    except Exception as e:
        messages.error(request, e)
    else:
        messages.success(
            request,
            'Your request was sent to the openbare Admins' +
            ' and will be evaluated.'
        )
    return redirect(reverse('library:index'))
项目:openbare    作者:openbare    | 项目源码 | 文件源码
def _admin_emails():
    return ["%s <%s>" % (admin[0], admin[1]) for admin in settings.ADMINS]
项目:django-tmpl    作者:jarrekk    | 项目源码 | 文件源码
def __init__(self, subject, message, fail_silently=False, html_message=None, connection=None):
        self.connection = connection
        self.subject = subject
        self.message = message
        self.recipient_list = [a[1] for a in settings.ADMINS]
        self.from_email = settings.SERVER_EMAIL
        self.fail_silently = fail_silently
        self.html_message = html_message
        threading.Thread.__init__(self)
项目:django-tmpl    作者:jarrekk    | 项目源码 | 文件源码
def run(self):
        if not settings.ADMINS:
            return
        mail = EmailMultiAlternatives('%s%s' % (settings.EMAIL_SUBJECT_PREFIX, self.subject),
                                      self.message, settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
                                      connection=self.connection)
        if self.html_message:
            mail.attach_alternative(self.html_message, 'text/html')
        try:
            mail.send(fail_silently=self.fail_silently)
        except Exception as e:
            logger.exception(e)
项目:CodingDojo    作者:ComputerSocietyUNB    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives('%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject),
                message, settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
                connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:NarshaTech    作者:KimJangHyeon    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives(
        '%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message,
        settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
        connection=connection,
    )
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:Scrum    作者:prakharchoudhary    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives(
        '%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message,
        settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
        connection=connection,
    )
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:django    作者:alexsukhrin    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives(
        '%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message,
        settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
        connection=connection,
    )
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:site    作者:alphageek-xyz    | 项目源码 | 文件源码
def send_email(self, request=None):

        emails = [EmailMultiAlternatives(**{
            'subject'    : 'Contact Form: ' + str(self.instance.name),
            'to'         : [mkemail(*a) for a in settings.ADMINS],
            'reply_to'   : [mkemail(str(self.instance.name), self.cleaned_data['email'])],
            'body'       : str().join('{0:15s} : {1}\n'.format(
                            self.fields[f].label, self.cleaned_data[f])
                            for f in self._meta.fields),
        })]

        emails[0].attach_alternative(
            render_to_string('contact/email.html',
                context={
                    'name'    : str(self.instance.name),
                    'phone'   : self.cleaned_data['phone'],
                    'email'   : self.cleaned_data['email'],
                    'comment' : self.cleaned_data['comment'],
                },
                request=request
            ), 'text/html'
        )

        if self.cleaned_data['cc_myself']:
            emails.append(copy.copy(emails[0]))
            emails[1].to = emails[0].reply_to
            emails[1].reply_to = [settings.DEFAULT_REPLY_ADDR]

        try:
            with get_connection() as con:
                con.send_messages(emails)
                con.close()
        except BadHeaderError as e:
            return HttpResponse(' '.join(
                ['BadHeaderError:'] + list(e.args)
            ))
        except Exception as e: # pragma: no cover
            print(e)
            return False
        return True
项目:steemprojects.com    作者:noisy    | 项目源码 | 文件源码
def handle(self, *args, **options):

        github = github_login(token=settings.GITHUB_TOKEN)

        for index, package in enumerate(Project.objects.iterator()):
            logging.info("{} ...".format(package.name))
            print("{} ...".format(package.name))

            # Simple attempt to deal with Github rate limiting
            while True:
                if github.ratelimit_remaining < 50:
                    sleep(120)
                break

            try:
                try:
                    package.fetch_metadata(fetch_pypi=False)
                    package.fetch_commits()
                except Exception as e:
                    raise PackageUpdaterException(e, package.name)
            except PackageUpdaterException:
                pass  # We've already caught the error so let's move on now

            sleep(5)

        message = "TODO - load logfile here"  # TODO
        send_mail(
            subject="Package Updating complete",
            message=message,
            from_email=settings.DEFAULT_FROM_EMAIL,
            recipient_list=[x[1] for x in settings.ADMINS]
        )
项目:intake    作者:codeforamerica    | 项目源码 | 文件源码
def send_email_to_admins(subject, message):
    """Asynchronously sends an email alert to all ADMINs in settings
    """
    tasks.send_email.delay(
        subject=subject, message=message,
        from_email=settings.MAIL_DEFAULT_SENDER,
        recipient_list=[email for name, email in settings.ADMINS])
项目:Gypsy    作者:benticarlos    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives(
        '%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message,
        settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
        connection=connection,
    )
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:DjangoBlog    作者:0daybug    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives('%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject),
                message, settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
                connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:wanblog    作者:wanzifa    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives('%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject),
                message, settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
                connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:tabmaster    作者:NicolasMinghetti    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives('%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject),
                message, settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
                connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:trydjango18    作者:lucifer-yqh    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives('%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject),
                message, settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
                connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:trydjango18    作者:wei0104    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives('%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject),
                message, settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
                connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:ims    作者:ims-team    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives(
        '%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message,
        settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
        connection=connection,
    )
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:lifesoundtrack    作者:MTG    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives(
        '%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message,
        settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
        connection=connection,
    )
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:django-open-lecture    作者:DmLitov4    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives(
        '%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message,
        settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
        connection=connection,
    )
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:travlr    作者:gauravkulkarni96    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives(
        '%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message,
        settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
        connection=connection,
    )
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:django-basic    作者:igor-chepurnoi    | 项目源码 | 文件源码
def contact(self):
        subject = self.cleaned_data['subject']
        from_email = self.cleaned_data['email']
        message = self.cleaned_data['body']

        try:
            return send_mail(subject, message, from_email, settings.ADMINS)
        except SMTPResponseException:
            return False
项目:logo-gen    作者:jellene4eva    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives('%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject),
                message, settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
                connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:liberator    作者:libscie    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives(
        '%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message,
        settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
        connection=connection,
    )
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:gmail_scanner    作者:brandonhub    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives('%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject),
                message, settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
                connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:djanoDoc    作者:JustinChavez    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives('%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject),
                message, settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
                connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:CSCE482-WordcloudPlus    作者:ggaytan00    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives(
        '%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message,
        settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
        connection=connection,
    )
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:tissuelab    作者:VirtualPlants    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives('%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject),
                message, settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
                connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:mercurysms    作者:HackCU    | 项目源码 | 文件源码
def handle(self, *args, **options):

        if User.objects.count() == 0:
            for user in settings.ADMINS:
                username = user
                password = 'admin'
                print('Creating account for %s' % (username,))
                admin = User.objects.create_superuser(email='', username=username, password=password)
                admin.is_active = True
                admin.is_admin = True
                admin.save()
        else:
            print('Admin accounts can only be initialized if no Accounts exist')
项目:producthunt    作者:davidgengler    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives(
        '%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message,
        settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
        connection=connection,
    )
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:django-rtc    作者:scifiswapnil    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives(
        '%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message,
        settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
        connection=connection,
    )
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:geekpoint    作者:Lujinghu    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives('%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject),
                message, settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
                connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:Kiwi    作者:kiwitcms    | 项目源码 | 文件源码
def mailto(template_name, subject, recipients=None,
           context=None, sender=settings.DEFAULT_FROM_EMAIL,
           cc=None):
    # make a list with recipients and filter out duplicates
    if isinstance(recipients, list):
        recipients = list(set(recipients))
    else:
        recipients = [recipients]

    # extend with the CC list
    if cc:
        recipients.extend(cc)

    # if debugging then send to ADMINS as well
    if settings.DEBUG:
        for (admin_name, admin_email) in settings.ADMINS:
            recipients.append(admin_email)

    body = render_to_string(template_name, context)

    email_thread = threading.Thread(
        target=send_mail,
        args=(settings.EMAIL_SUBJECT_PREFIX + subject, body, sender, recipients),
        kwargs={'fail_silently': False}
    )
    # This is to tell Python not to wait for the thread to return
    email_thread.setDaemon(True)
    email_thread.start()
项目:django-next-train    作者:bitpixdigital    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives('%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject),
                message, settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
                connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:LatinSounds_AppEnviaMail    作者:G3ek-aR    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives(
        '%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message,
        settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
        connection=connection,
    )
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:DjangoZeroToHero    作者:RayParra    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives('%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject),
                message, settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
                connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:Roboism    作者:markroxor    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives('%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject),
                message, settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
                connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
项目:bring_the_idea    作者:GrigoriyMikhalkin    | 项目源码 | 文件源码
def handle(self, *args, **options):
        for user in settings.ADMINS:
            username = user[0].replace(" ","")
            email = user[1]
            password = user[2]
            self.stdout.write("Adding new admin user '%s'(%s)" % (username, email))

            try:
                User.objects.create_superuser(username, email, password)
            except IntegrityError:
                raise CommandError("Can't create admin user with name '%s'" % username)
            self.stdout.write(self.style.SUCCESS("Admin user '%s' is registered" % username))
项目:django-wechat-api    作者:crazy-canux    | 项目源码 | 文件源码
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives('%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject),
                message, settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
                connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)